Kafka-client 0.10.0 API问题
2017-11-22 本文已影响153人
Woople
注:本文涉及到的环境版本为kafka 0.10.0
在使用kafka 0.10.0 API获取consumer offset的时候,遇到卡住的问题,类似KAFKA-3296-All consumer reads hang indefinately。
分析步骤
- 打开debug日志,可以看到下面这样的日志内容
responseBody={error_code=15,coordinator={node_id=-1,host=,port=-1}}
- 运行
kafka-topics.sh --describe --zookeeper localhost:2181 --topic __consumer_offsets
,得到结果
Topic:__consumer_offsets PartitionCount:50 ReplicationFactor:3 Configs:segment.bytes=104857600,cleanup.policy=compact,compression.type=producer
Topic: __consumer_offsets Partition: 0 Leader: -1 Replicas: 1003,1004,1007 Isr:
Topic: __consumer_offsets Partition: 1 Leader: 1005 Replicas: 1005 Isr: 1005
Topic: __consumer_offsets Partition: 2 Leader: 1005 Replicas: 1005 Isr: 1005
Topic: __consumer_offsets Partition: 3 Leader: 1001 Replicas: 1001 Isr: 1001,1003,1002
Topic: __consumer_offsets Partition: 4 Leader: 1002 Replicas: 1002,1001,1003 Isr: 1001
Topic: __consumer_offsets Partition: 5 Leader: -1 Replicas: 1002,1007,1008 Isr:
Topic: __consumer_offsets Partition: 6 Leader: -1 Replicas: 1003,1008,1009 Isr:
可以看到有很多partition已经没有leader。
解决方法
-
停止kafka集群
-
在zk上删除
/brokers/topics/__consumer_offsets
-
启动kafka集群
-
启动应用程序
-
在通过
kafka-topics.sh --describe
命令可以看到__consumer_offsets
的所有leader已经正常