删除kafka消费者组

半兽人 发表于: 2021-07-13   最后更新时间: 2021-09-16 14:39:36  
{{totalSubscript}} 订阅, 8,148 游览

你可以通过使用Kafka客户端的Kafka命令行工具从Kafka实例中删除消费者组。

查询消费者组列表:

kafka-consumer-groups.sh --bootstrap-server 172.31.1.245:9092 --list

查询消费者组明细:

kafka-consumer-groups.sh --bootstrap-server {Kafka instance connection address} --describe --group {consumer group name}

如:

[root@zk-server-1 bin]#  ./kafka-consumer-groups.sh --bootstrap-server 172.31.1.245:9091,172.31.1.86:9091,172.31.1.128:9091 --describe --group bbbb
Note: This will not show information about old Zookeeper-based consumers.
Consumer group 'bbbb' has no active members.

TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID     HOST            CLIENT-ID
test            1          336             336             0               -               -               -
test            0          334             334             0               -               -               -
test            2          334             334             0               -

删除消费者组:

kafka-consumer-groups.sh --bootstrap-server {Kafka instance connection address} --delete --group {consumer group name}

如:

[root@zk-server-1 bin]# ./kafka-consumer-groups.sh --bootstrap-server 172.31.1.245:9091,172.31.1.86:9091,172.31.1.128:9091 --delete --group bbbb
Note: This will not show information about old Zookeeper-based consumers.
Deletion of requested consumer groups ('bbbb') was successful.
更新于 2021-09-16

笃搏超 3年前
MacBook-Pro-3:kafka_2.12-0.11.0.1 zc$ bin/kafka-consumer-groups.sh --bootstrap-server 10.9.253.80:9092 --group member-risk-flink --describe
Note: This will only show information about consumers that use the Java consumer API (non-ZooKeeper-based consumers).

Consumer group 'member-risk-flink' has no active members.

TOPIC                          PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG        CONSUMER-ID                                       HOST                           CLIENT-ID
member-risk-abstraction-calculate-input 3          5               5               0          -                                                 -                              -
member-risk-abstraction-calculate-input 0          4               4               0          -                                                 -                              -
member-risk-abstraction-calculate-input 2          4               4               0          -                                                 -                              -
member-risk-abstraction-calculate-input 1          2               2               0          -                                                 -                              -


MacBook-Pro-3:kafka_2.12-0.11.0.1 zc$ bin/kafka-consumer-groups.sh --bootstrap-server 10.9.253.80:9092 --list
Note: This will only show information about consumers that use the Java consumer API (non-ZooKeeper-based consumers).


MacBook-Pro-3:kafka_2.12-0.11.0.1 zc$ bin/kafka-consumer-groups.sh --bootstrap-server 10.9.253.80:9092 --delete --group member-risk-flink
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.


MacBook-Pro-3:kafka_2.12-0.11.0.1 zc$ bin/kafka-consumer-groups.sh --zookeeper 10.9.253.80:2181  --delete --group member-risk-flink
Note: This will only show information about consumers that use ZooKeeper (not those using the Java consumer API).

Error: Delete for group 'member-risk-flink' failed because group does not exist.
半兽人 -> 笃搏超 3年前

list已经没有消费者了,你只能删除查到的

Consumer group 'member-risk-flink' has no active members.
查看kafka更多相关的文章或提一个关于kafka的问题,也可以与我们一起分享文章