2025年kafka:修改 topic的offset

kafka:修改 topic的offset查询 topic 的 offset 的范围 用下面命令可以查询到 topic test broker suna 9092 的 offset 的最小值 bin kafka run class sh kafka tools GetOffsetShe broker list suna 9092 topic test time 2 输出 test 0 1288

大家好,我是讯享网,很高兴认识大家。

查询topic的offset的范围

用下面命令可以查询到topic:test broker:suna:9092的offset的最小值:

 

设置consumer group的offset

启动zookeeper client


讯享网

手动更新Kafka存在Zookeeper中的偏移量。我们有时候需要手动将某个主题的偏移量设置成某个值,这时候我们就需要更新Zookeeper中的数据了。Kafka内置为我们提供了修改偏移量的类:kafka.tools.UpdateOffsetsInZK,我们可以通过它修改Zookeeper中某个主题的偏移量,具体操作如下:

[ ~]$ bin/kafka-run-class.sh kafka.tools.UpdateOffsetsInZK
USAGE: kafka.tools.UpdateOffsetsInZK$ [earliest | latest] consumer.properties topic
在不输入参数的情况下,我们可以得知kafka.tools.UpdateOffsetsInZK类需要输入的参数。我们的consumer.properties文件配置内容如下:

zookeeper.connect=www.iteblog.com:2181
 
# timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=6000
 
#consumer group id
group.id=group
这个工具只能把Zookeeper中偏移量设置成earliest或者latest,如下:

[ ~]$ bin/kafka-run-class.sh kafka.tools.UpdateOffsetsInZK  \
     earliest config/consumer.properties iteblog
updating partition 0 with new offset:
updating partition 1 with new offset:
updating partition 2 with new offset:
updating partition 3 with new offset:
updating partition 4 with new offset:
updating partition 5 with new offset:
updating partition 6 with new offset:
updating partition 7 with new offset:
updating partition 8 with new offset:
updating partition 9 with new offset:
updating partition 10 with new offset:
updated the offset for 11 partitions

原文参考:https://blog.csdn.net/yxgxy/article/details/?utm_source=blogxgwz2

小讯
上一篇 2025-01-10 18:39
下一篇 2025-02-28 10:42

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/106735.html