【问题标题】:how to get the group commit offset from kafka(0.10.x)如何从kafka(0.10.x)获取组提交偏移量
【发布时间】:2016-12-12 17:17:52
【问题描述】:

该组的偏移信息之前存储在zookeeper中。现在,在 Kafka 集群 (0.10.x) 中,偏移量信息存储在名为 __consumer_offsets 的主题中。

但是我怎样才能得到我指定的组的偏移量信息呢?

【问题讨论】:

标签: apache-kafka


【解决方案1】:

对于活动组,调用下面的命令来检索偏移量:

bin/kafka-consumer-groups.sh --bootstrap-server broker1:9092 --describe --group test-consumer-group

对于非活动组,首先通过计算Math.abs(groupId.hashCode()) % 50得到目标偏移主题分区数,然后调用:

bin/kafka-simple-consumer-shell.sh --topic __consumer_offsets --partition <calculated number> --broker-list broker1:9092 --formatter "kafka.coordinator.GroupMetadataManager\$OffsetsMessageFormatter"

查找组的偏移量。

【讨论】:

  • kafka-consumer-groups.sh的脚本只能获取zookeeper中存储的信息,而offset信息仅存储在topic中。
  • 不完全是。当指定“--bootstrap-server”时,它会检查偏移量主题。指定“--zookeeper”表示老消费者。
  • 它有效,谢谢。我失败的原因是因为我使用的集群启动了安全认证,kafka-consumer-groups.sh的脚本没有做相应的改变。
  • 我发现kafka-consumer-groups.sh--all-groups 选项非常有用。它还显示非活动组。
猜你喜欢
  • 2018-07-01
  • 2021-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-02
  • 2021-04-06
  • 1970-01-01
  • 2022-11-13
相关资源
最近更新 更多