本文介绍了如何从kafka(0.10.x)获取组提交偏移量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
该组的偏移量信息之前已存储在zookeeper中.现在,在Kafka群集(0.10.x)中,偏移量信息存储在名为 __ consumer_offsets
的主题中.
The offsets informations of the group were stored in zookeeper before. Now, in the Kafka Cluster (0.10.x), the offsets informations are stored in the topic which's name is __consumer_offsets
.
但是如何获取指定的组的偏移量信息?
But how could I get the offsets information of the group which I specified?
推荐答案
对于活动组,调用以下命令以获取偏移量:
For active groups, invoke command below to retrieve the offsets:
bin/kafka-consumer-groups.sh --bootstrap-server broker1:9092 --describe --group test-consumer-group
对于非活动组,首先通过计算Math.abs(groupId.hashCode())%50获得目标偏移主题分区号,然后调用:
For inactive groups, first get the target offset topic partition number by calculating Math.abs(groupId.hashCode()) % 50, then invoke:
bin/kafka-simple-consumer-shell.sh --topic __consumer_offsets --partition <calculated number> --broker-list broker1:9092 --formatter "kafka.coordinator.GroupMetadataManager\$OffsetsMessageFormatter"
查找组的偏移量.
这篇关于如何从kafka(0.10.x)获取组提交偏移量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!