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

  • 重置所有消费组的所有Topic的偏移量
PS C:\Users\chenjing\kafka_2.12-3.3.1> .\bin\windows\kafka-consumer-groups.bat --bootstrap-server 192.168.31.253:9092 --reset-offsets --to-earliest --all-groups --dry-run --all-topicsGROUPTOPICPARTITIONNEW-OFFSETOrderCountert220OrderCountert100OrderCountert210OrderCountert200CountryCounteruser_card10CountryCounteruser_card0521CountryCounteruser_card20CountryCountert100
  • 重置所有消费组中指定Topic的偏移量
PS C:\Users\chenjing\kafka_2.12-3.3.1> .\bin\windows\kafka-consumer-groups.bat --bootstrap-server 192.168.31.253:9092 --reset-offsets --to-earliest --all-groups --dry-run --topic t1GROUPTOPICPARTITIONNEW-OFFSETOrderCountert100CountryCountert100--shift-by <Long: number-of-offsets>
Reset offsets shifting current offset by 'n', where 'n' can be positive or negative.
--state [String]
When specified with '--describe', includes the state of the group. Example: --bootstrap-server localhost:9092 --describe --group group1 --state
--describe 配合使用,列出消费者组的状态 。例如:
  • 列出指定消费者组的状态
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 --stateGROUPCOORDINATOR (ID)ASSIGNMENT-STRATEGYSTATE#MEMBERSCountryCounter192.168.31.253:9092 (0)rangeStable1
  • 列出所有消费者组的状态
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 --describe --stateGROUPCOORDINATOR (ID)ASSIGNMENT-STRATEGYSTATE#MEMBERSCountryCounter192.168.31.253:9092 (0)rangeStable1GROUPCOORDINATOR (ID)ASSIGNMENT-STRATEGYSTATE#MEMBERSOrderCounter192.168.31.253:9092 (0)rangeStable1--timeout <Long: timeout (ms)>
The timeout that can be set for some use cases. For example, it can be used when describing the group to specify the maximum amount of time in milliseconds to wait before the group stabilizes (when the group is just created, or is going through some changes). (default: 5000)
可以为某些用例设置的超时 。例如,在显示消费者组的详情时,可以使用它来指定在组稳定之前等待的最长时间(以毫秒为单位)(当组刚刚创建或正在经历一些更改时),默认值:5000
--topic
The topic whose consumer group information should be deleted or topic whose should be included in the reset offset process. In reset-offsets case, partitions can be specified using this format: topic1:0,1,2, where 0,1,2 are the partition to be included in the process. Reset-offsets also supports multiple topic inputs.
配合其他命令指定主题名
--verbose
Provide additional information, if any, when describing the group. This option may be used with '--offsets'/'--members'/'--state' and '--bootstrap-server' options only.
Example: --bootstrap-server localhost:9092 --describe --group group1 --members --verbose
在描述组时提供其他信息(如果有的话) 。此选项只能与 --offsets --members --state --bootstrap-server 选项一起使用 。
--version
Display Kafka version.
打印Kafka版本号
【kafka-consumer-groups 命令行工具使用手册】

经验总结扩展阅读