kafka-consumer-groups 命令行工具使用手册

kafka-consumer-groups 命令行工具使用手册该手册原文出自 $KAFKA_HOME\bin\windows\kafka-consumer-groups.bat --help 命令的输出结果,并由 Redisant 提供翻译和测试用例 。
--all-groups

Apply to all consumer groups.
指定所有的消费者组 。和 --describe, --delete, --reset-offsets, --delete-offsets 配合使用
--all-topics
Consider all topics assigned to a group in the reset-offsets process.
指定所有的消费者组 。和 --reset-offsets 配合使用
--bootstrap-server
REQUIRED: The server(s) to connect to.
必填项,Kafka服务器的地址和端口 。
--by-duration
Reset offsets to offset by duration from current timestamp. Format: 'PnDTnHnMnS'
--command-config
Property file containing configs to be passed to Admin Client and Consumer.
--delete
Pass in groups to delete topic partition offsets and ownership information over the entire consumer group. For instance --group g1 --group g2
删除整个消费者组(包括已保存的偏移量信息和所有权信息),在执行该操作之前,必须关闭所有的消费者 。
  • 删除所有的消费者组
PS C:\Users\chenjing\kafka_2.12-3.3.1> .\bin\windows\kafka-consumer-groups.bat --bootstrap-server 192.168.31.253:9092 --all-groups CountryCounter --deleteDeletion of requested consumer groups ('CountryCounter', 'OrderCounter') was successful.
  • 删除指定的消费者组
PS C:\Users\chenjing\kafka_2.12-3.3.1> .\bin\windows\kafka-consumer-groups.bat --bootstrap-server 192.168.31.253:9092 --group CountryCounter --deleteDeletion of requested consumer groups ('CountryCounter') was successful.--delete-offsets
Delete offsets of consumer group. Supports one consumer group at the time, and multiple topics.
删除消费者组的偏移量 。例如:
PS C:\Users\chenjing\kafka_2.12-3.3.1> .\bin\windows\kafka-consumer-groups.bat --bootstrap-server 192.168.31.253:9092 --delete-offsets --group CountryCounter --topic t1--describe
Describe consumer group and list offset lag (number of messages not yet processed) related to given group.
列出消费者组里所有主题的信息和每个分区的偏移量 。例如:
  • 查看指定的消费者组:
PS C:\Users\chenjing\kafka_2.12-3.3.1> .\bin\windows\kafka-consumer-groups.bat --bootstrap-server 192.168.31.253:9092 --group CountryCounter --describeGROUPTOPICPARTITIONCURRENT-OFFSETLOG-END-OFFSETLAGCONSUMER-IDHOSTCLIENT-IDCountryCounteruser_card02142140chenjing_client-42cc37c6-695f-4c47-b844-764a3d2169d3 /111.18.132.232 chenjing_clientCountryCountert101891890chenjing_client-42cc37c6-695f-4c47-b844-764a3d2169d3 /111.18.132.232 chenjing_client
  • 查看所有的消费者组:
PS C:\Users\chenjing\kafka_2.12-3.3.1> .\bin\windows\kafka-consumer-groups.bat --bootstrap-server 192.168.31.253:9092 --all-groups --describeGROUPTOPICPARTITIONCURRENT-OFFSETLOG-END-OFFSETLAGCONSUMER-IDHOSTCLIENT-IDCountryCounteruser_card02142140chenjing_client-42cc37c6-695f-4c47-b844-764a3d2169d3 /111.18.132.232 chenjing_clientCountryCountert101891890chenjing_client-42cc37c6-695f-4c47-b844-764a3d2169d3 /111.18.132.232 chenjing_clientGROUPTOPICPARTITIONCURRENT-OFFSETLOG-END-OFFSETLAGCONSUMER-IDHOSTCLIENT-IDOrderCountert101891890client_2-26992db5-d5ab-4252-a219-995bdbe37388 /111.18.132.232 client_2OrderCountert20125712570client_2-26992db5-d5ab-4252-a219-995bdbe37388 /111.18.132.232 client_2--group
The consumer group we wish to act on.
配合其他命令执行消费者组
--help
Print usage information.
打印帮助手册
--list
List all consumer groups.
列出所有的消费者组 。例如:
PS C:\Users\chenjing\kafka_2.12-3.3.1> .\bin\windows\kafka-consumer-groups.bat --bootstrap-server 192.168.31.253:9092 --listOrderCounterCountryCounter--members
Describe members of the group. This option may be used with '--describe' and '--bootstrap-server' options only. Example: --bootstrap-server localhost:9092 --describe --group group1 --members
查看消费者组里有哪些成员,该选项只能和 --describe--bootstrap-server 一起使用 。例如:
  • 查看指定的消费者组里有哪些成员
PS C:\Users\chenjing\kafka_2.12-3.3.1> .\bin\windows\kafka-consumer-groups.bat --bootstrap-server 192.168.31.253:9092 --group CountryCounter --describe --membersGROUPCONSUMER-IDHOSTCLIENT-ID#PARTITIONSCountryCounterchenjing_client-42cc37c6-695f-4c47-b844-764a3d2169d3 /111.18.132.232 chenjing_client 2

推荐阅读