如何删除Kafka消费者组以重置胶印? [英] How do I delete a Kafka Consumer Group to reset offsets?
问题描述
我想删除Kakfa使用者组,以便当应用程序创建使用者并订阅主题时,它可以从主题数据的开头开始.
I want to delete a Kakfa consumer group so that when the application creates a consumer and subscribes to a topic it can start at the beginning of the topic data.
这是使用当前最新的Confluent Platform 3.1.2(使用Kafka 0.10.1.1.)的单节点开发虚拟机.
This is with a single node development vm using the current latest Confluent Platform 3.1.2 which uses Kafka 0.10.1.1.
我尝试普通语法:
sudo /usr/bin/kafka-consumer-groups --new-consumer --bootstrap-server localhost:9092 --delete --group my_consumer_group
我得到了错误:
Option [delete] is only valid with [zookeeper]. Note that there's no need to delete group metadata for the new consumer as the group is deleted when the last committed offset for that group expires.
如果我尝试使用zookeeper变体:
If I try the zookeeper variant:
sudo /usr/bin/kafka-consumer-groups --zookeeper localhost:2181 --delete --group my_consumer_group
我得到:
Delete for group my_consumer_group failed because group does not exist.
如果我使用旧"消费者列出,则看不到我的消费者组(或任何其他消费者组)
If I list using the "old" consumer, I do not see my consumer group (or any other consumer groups)
sudo /usr/bin/kafka-consumer-groups --zookeeper localhost:2181 --list
如果我使用新"消费者列出,我可以看到我的消费者组,但显然不能删除它:
If I list using the "new" consumer, I can see my consumer group but apparently I can't delete it:
sudo /usr/bin/kafka-consumer-groups --new-consumer --bootstrap-server localhost:9092 --list
推荐答案
使用Kafka 0.10.2升级到刚刚发布的Confluent Platform 3.2可以解决我的基本问题.现在,当我删除主题时,偏移信息已正确重置.因此,当我使用相同的名称创建主题时,使用者将从新数据的开头开始.
Upgrading to the just released Confluent Platform 3.2 with Kafka 0.10.2 solved my underlying issue. When I delete a topic, offset information is now correctly reset. So when I create a topic with the same name, consumers start from the beginning of the new data.
我仍然无法使用kafka-consumer-groups
工具删除新的消费群体,但是我的基本问题已解决.
I still can't delete new style consumer groups with the kafka-consumer-groups
tool, but my underlying issue is solved.
在Kafka 0.10.2之前,曾有黑客入侵,但没有针对此问题的干净解决方案.
Before Kafka 0.10.2, there were hacks, but no clean solution to this issue.
这篇关于如何删除Kafka消费者组以重置胶印?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!