如何删除 Kafka Consumer Group 以重置偏移量? [英] How do I delete a Kafka Consumer Group to reset offsets?

查看:168
本文介绍了如何删除 Kafka Consumer Group 以重置偏移量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除一个 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 Consumer Group 以重置偏移量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆