Kafka-client 0.10.0 API问题

注:本文涉及到的环境版本为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。

解决方法


  1. 停止kafka集群

  2. 在zk上删除/brokers/topics/__consumer_offsets

  3. 启动kafka集群

  4. 启动应用程序

  5. 在通过kafka-topics.sh --describe命令可以看到__consumer_offsets的所有leader已经正常

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容