这个问题是同事遇到的:
错误信息:
ERROR Error when sending message to topic test with key: null, value: 5 bytes with error: (org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
org.apache.kafka.common.errors.TimeoutException: Batch containing 1 record(s) expired due to timeout while requesting metadata from brokers for test-0
原先使用的是0.8.1.1版本的kafka,换成0.10.0.1版本的kafka之后,仍然使用之前创建的topic test,就会一直出现这个错误。
当我使用新版本的kafka创建一个新的topic,进行测试,发现问题就没有了。判定是两个版本的topic不能通用,代码可能实现不一致导致的。
配置:offsets.topic.replication.factor=1
The reason was successfully found in logs : Number of alive brokers '1' does not meet the required replication factor '3' for the offsets topic you need to post into your server.properties file following option : offsets.topic.replication.factor=1. This option will not let you do anything till the count reaches 3 but since you have it set as a playbox - you usually have 1 only.
延申:
1.检查各个broker的机器上的jdk版本,最好保持一致
2.检查各个zookeeper版本,要求一致
3.检查kafka版本,要求一致。