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 --delete
Deletion 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 --delete
Deletion 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 --describeGROUP           TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                          HOST            CLIENT-ID
CountryCounter  user_card       0          214             214             0               chenjing_client-42cc37c6-695f-4c47-b844-764a3d2169d3 /111.18.132.232 chenjing_client
CountryCounter  t1              0          189             189             0               chenjing_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 --describeGROUP           TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                          HOST            CLIENT-ID
CountryCounter  user_card       0          214             214             0               chenjing_client-42cc37c6-695f-4c47-b844-764a3d2169d3 /111.18.132.232 chenjing_client
CountryCounter  t1              0          189             189             0               chenjing_client-42cc37c6-695f-4c47-b844-764a3d2169d3 /111.18.132.232 chenjing_clientGROUP           TOPIC           PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG             CONSUMER-ID                                   HOST            CLIENT-ID
OrderCounter    t1              0          189             189             0               client_2-26992db5-d5ab-4252-a219-995bdbe37388 /111.18.132.232 client_2
OrderCounter    t2              0          1257            1257            0               client_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 --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 一起使用。例如:

  • 查看指定的消费者组里有哪些成员
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 --membersGROUP           CONSUMER-ID                                          HOST            CLIENT-ID       #PARTITIONS
CountryCounter  chenjing_client-42cc37c6-695f-4c47-b844-764a3d2169d3 /111.18.132.232 chenjing_client 2
  • 查看所有的消费者组里有哪些成员
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 --membersGROUP           CONSUMER-ID                                          HOST            CLIENT-ID       #PARTITIONS
CountryCounter  chenjing_client-42cc37c6-695f-4c47-b844-764a3d2169d3 /111.18.132.232 chenjing_client 2GROUP           CONSUMER-ID                                   HOST            CLIENT-ID       #PARTITIONS
OrderCounter    client_2-26992db5-d5ab-4252-a219-995bdbe37388 /111.18.132.232 client_2        2

--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 以真正更新偏移量):

  • 重置指定消费组的所有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 --group CountryCounter --dry-run --all-topicsGROUP                          TOPIC                          PARTITION  NEW-OFFSET
CountryCounter                 user_card                      1          0
CountryCounter                 user_card                      0          521
CountryCounter                 user_card                      2          0
CountryCounter                 t1                             0          0
  • 重置指定消费组的指定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 --group CountryCounter --dry-run --topic t1GROUP                          TOPIC                          PARTITION  NEW-OFFSET
CountryCounter                 t1                             0          0
  • 重置所有消费组的所有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-topicsGROUP                          TOPIC                          PARTITION  NEW-OFFSET
OrderCounter                   t2                             2          0
OrderCounter                   t1                             0          0
OrderCounter                   t2                             1          0
OrderCounter                   t2                             0          0
CountryCounter                 user_card                      1          0
CountryCounter                 user_card                      0          521
CountryCounter                 user_card                      2          0
CountryCounter                 t1                             0          0
  • 重置所有消费组中指定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 t1GROUP                          TOPIC                          PARTITION  NEW-OFFSET
OrderCounter                   t1                             0          0
CountryCounter                 t1                             0          0

--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 --stateGROUP                     COORDINATOR (ID)          ASSIGNMENT-STRATEGY  STATE           #MEMBERS
CountryCounter            192.168.31.253:9092 (0)   range                Stable          1
  • 列出所有消费者组的状态
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 --stateGROUP                     COORDINATOR (ID)          ASSIGNMENT-STRATEGY  STATE           #MEMBERS
CountryCounter            192.168.31.253:9092 (0)   range                Stable          1GROUP                     COORDINATOR (ID)          ASSIGNMENT-STRATEGY  STATE           #MEMBERS
OrderCounter              192.168.31.253:9092 (0)   range                Stable          1

--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.sh 命令行工具使用手册,附测试用例相关推荐

  1. 《现代命令行工具指南》11. 帮助手册:只给你最有用的帮助信息 - tldr

    ​好工具就是生产力,这是专栏<现代命令行工具指南>精讲的第 11 个命令行工具,欢迎品鉴. 命令行工具太多了,我们不可能把所有命令的用法都记住,因此帮助手册(man)就成了我们经常查阅的东 ...

  2. Kafka 命令行工具 kcat/kafkacat

    简介 kcat, 又称为 kafkacat,是一款非 JVM 的 Kafka 消息生产和消费的命令行工具,适用于 Kafka 0.8 及以上版本. github地址: https://github.c ...

  3. linux运行16668端口,Linux 性能监控之命令行工具

    引言 对于系统和网络管理员来说每天监控和调试Linux系统的性能问题是一项繁重的工作.这些命令行工具可以在各种Linux系统下使用,可以用于监控和查找产生性能问题的原因.这个命令行工具列表提供了足够的 ...

  4. 实用!五款新型 Linux 命令行工具

    使用新的替代工具来改进旧的命令行工具. 作者 | Ricardo Gerardi 译者 | 弯月,责编 | 屠敏 出品 | CSDN(ID:CSDNnews) 以下为译文: 在Linux/Unix系统 ...

  5. Windows 软件管理命令行工具scoop介绍

    我们知道Mac 上的brew,Ubuntu 上的apt命令行工具可以方便用来管理软件 类似的Windows 实际上也有一个开源命令行软件管理工具 Scoop下载地址(https://github.co ...

  6. 自己写的python软件可以在哪发布-如何发布一个Python命令行工具

    本文简介 上次写的一个终端里面斗鱼TV弹幕Python版本和Ruby版本,并且发布到PIP和RubyGems上面.在发布PIP包的时候,居然Google不到一篇可以非常好的讲解这个流程的文章.于是整理 ...

  7. 有哪些命令行工具堪称神器?

    过去几年,在 GitHub 上见到过不少优质的项目,其中不乏特别实用,能大幅提升生产力的命令行工具. 今天在这里就简单整理下,跟大家分享几个比较实用的命令行工具吧. mas 一个 Mac 应用商店命令 ...

  8. ZooKeeper命令、命令行工具及简单操作

    常用命令 ZooKeeper 支持某些特定的四字命令字母与其的交互.它们大多是查询命令,用来获取 ZooKeeper 服务的当前状态及相关信息.用户在客户端可以通过 telnet 或 nc 向 Zoo ...

  9. 使用 ohmyzsh 打造 windows、ubuntu、mac 系统高效终端命令行工具

    如果觉得内容不错,可以设为星标置顶我的公众号 原标题名:oh my zsh 和 windows git bash 设置别名提高效率 写于2018年06月03日 在我的微信交流群中听闻很多前端开发比较贫 ...

最新文章

  1. ​Python数据可视化工具怎么选?深度评测5款实用工具
  2. 乘法器专题研究(内含所有类型乘法器)
  3. python time智能等待_python中等待怎么表示
  4. adb logcat通过包名过滤(dos命令find后跟变量)
  5. vim打开所有折叠的方法及其他所有折叠的命令
  6. 【Qt】Qt中的快捷键汇总
  7. 解决Vue跳转到当前路由报错问题
  8. c语言inline不起作用,C语言inline内联函数学习小结
  9. linux下达梦数据库启动_linux上安装tomcat和达梦数据库
  10. 数据库设计的范式规范
  11. proxmoxve打造云桌面_最大亮点!山东众志电子为山东财经大学东方学院打造首个200点位云桌面考场...
  12. 【SimpleITK】坐标次序问题
  13. python super()
  14. 一张图学会Python3的基本用法
  15. MySQL5.7官网参考手册路径
  16. Layer2 DAO基础协议Metis与IDO平台Paid Network达成战略合作
  17. 【LG-P5072 [Ynoi2015]】盼君勿忘
  18. OpenWrt上搭建纯L2TP服务器[ZT]
  19. 数学之美--数学大师与漂亮的分形几何学
  20. 人脸检测和人脸识别的基础知识

热门文章

  1. 我是个程序员,我崩溃了
  2. java jackson漏洞_CVE-2019-12086 jackson任意文件读取漏洞
  3. 2021 年苏州大学计算机考研专业课 872 真题 --- 数据结构部分
  4. (附源码)spring boot网上求职招聘系统 毕业设计081201
  5. mongo 查询显示字段_MongoDB查询指定字段(field)返回指定字段的方法
  6. 基金申请-4:如何检索国家基金科研项目?
  7. 一篇看懂CVPR 2017五大研究前沿 | 腾讯AI Lab深度解析
  8. 数据结构二叉排序树建立_数据结构101什么是二叉搜索树
  9. win10 | 频繁死机 鼠标键盘无响应: 尝试恢复 删掉的服务
  10. reader.exe 摸鱼神器 更换图标版!更隐蔽..阅读神器