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

删除整个消费者组(包括已保存的偏移量信息和所有权信息),在执行该操作之前,必须关闭所有的消费者。

--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.

列出消费者组里所有主题的信息和每个分区的偏移量。例如:

--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 --list
OrderCounter
CountryCounter

--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 一起使用。例如:

--reset-offsets

Reset offsets of consumer group. Supports one consumer group at the time, and instances should be inactive.

Has 2 execution options: –dry-run (the default) to plan which offsets to reset, and –execute to update the offsets. Additionally, the –export option is used to export the results to a CSV format.

You must choose one of the following reset specifications: –to-datetime, –by-duration, –to-earliest, –to-latest, –shift-by, –from-file, –to-current, –to-offset.

To define the scope use –all-topics or –topic. One scope must be specified unless you use ‘–from-file’.

重置消费者组的偏移量。如果执行消费者组,一次只能指定一个消费组(需要提前关闭相关的消费者和生产者)。有两个执行参数:--dry-run(默认值)用于打印计划要重置的偏移量,以及 --execute 以更新偏移量。此外,--export 选项用于将结果导出为 CSV 格式。 必须选择以下重置类型之一(关于这些重置类型的更多参考请查看 官方文档):--to-datetime, --by-duration, --to-earliest, --to-latest, --shift-by, --from-file, --to-current, --to-offset

例如(以下所有命令均使用 --dry-run 参数打印执行计划,如果执行计划符合你的期望,请把 --dry-run 替换为 --execute 以真正更新偏移量):

--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 配合使用,列出消费者组的状态。例如:

--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版本号