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

GROUP           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 --describe

GROUP           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 GROUP 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 --members

GROUP           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 --members

GROUP           CONSUMER-ID                                          HOST            CLIENT-ID       #PARTITIONS
CountryCounter chenjing_client-42cc37c6-695f-4c47-b844-764a3d2169d3 /111.18.132.232 chenjing_client 2 GROUP 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-topics

GROUP                          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 t1

GROUP                          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-topics

GROUP                          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 t1

GROUP                          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 --state

GROUP                     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 --state

GROUP                     COORDINATOR (ID)          ASSIGNMENT-STRATEGY  STATE           #MEMBERS
CountryCounter 192.168.31.253:9092 (0) range Stable 1 GROUP 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 命令行工具使用手册的更多相关文章

  1. 使用脚本+kafka自带命令行工具 统计数据写入kafka速率

    思路 每隔一段时间(比如说10秒)统计一次某topic的所有partition的最大offset值之和,这便是该topic的message总数. 然后除以间隔时间就可以粗略但方便得出 某topic的数 ...

  2. Apache Kafka系列(二) 命令行工具(CLI)

    Apache Kafka命令行工具(Command Line Interface,CLI),下文简称CLI. 1. 启动Kafka 启动Kafka需要两步: 1.1. 启动ZooKeeper [roo ...

  3. Linux 性能监控之命令行工具

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

  4. MySQL 命令行工具之 mysqldump 深入研究

    mysqldump 是MySQL的一个命令行工具,用于逻辑备份.可以将数据库和表的结构,以及表中的数据分别导出成:create database, create table, insert into的 ...

  5. **代码审查:Phabricator命令行工具Arcanist的基本用法

    Phabricator入门手册 http://www.oschina.net/question/191440_125562 Pharicator是FB的代码审查工具,现在我所在的团队也使用它来进行代码 ...

  6. mysql命令行工具

    mysql包相关命令行工具 [root@manage ~]# rpm -qa|grep mysql mysql-server-5.1.73-5.el6_7.1.x86_64 mysql-5.1.73- ...

  7. Apache Commons CLI 开发命令行工具示例

    概念说明Apache Commons CLI 简介 虽然各种人机交互技术飞速发展,但最传统的命令行模式依然被广泛应用于各个领域:从编译代码到系统管理,命令行因其简洁高效而备受宠爱.各种工具和系统都 提 ...

  8. 微软开放技术发布针对 Mac 和 Linux 的更新版 Azure Node.JS SDK 和命令行工具

    发布于 2013-12-04 作者 Eduard Koller 这次为我们使用Linux 的朋友带来了更多关于部署云上虚拟机的消息.今天,微软开放技术有限公司 (MS Open Tech),想与大家分 ...

  9. 如何在Linux中用命令行工具管理KVM虚拟环境

    第一步: 配置存储池 Virsh命令行工具是一款管理virsh客户域的用户界面,它能在命令行中运行所给的命令以及它的参数,我们要用它给我们的KVM环境创建存储池,想知道关于这个工具的更多信息,用以下这 ...

随机推荐

  1. 【面试题】Vue中的$router 和 $route的区别

    Vue中的$router 和 $route的区别 点击视频讲解更加详细 this.$route:当前激活的路由的信息对象.每个对象都是局部的,可以获取当前路由的 path, name, params, ...

  2. MongoDB,入门看这一篇足矣!

    一.介绍 在介绍 MongoDB 之前,我先介绍一下业务开发的时候遇到的痛点,以便大家对它有一个更加清晰的认识! 最近在用数据库存储数据的时候发现这么一个坑,例如从消息队列中监听消息的时候,原来的做法 ...

  3. qt unknown type name编译报错记录

    在classA中include class B,然后定义成员变量的时候,报错unknown type name了. 一共有两种可能造成这种问题: 1.circle include,同时在classA中 ...

  4. 截取url后缀扩展名方法

    原本使用 Path(_['video']['downloadUrl']).suffix 获取文件扩展名,没想到出错了,查明原因发现某视频链接是https://xx.xxx.xxx/xx/xxxx.mp ...

  5. PHP代码审计——文件操作漏洞

    梦想CMS(lmxcms)任意文件删除 1. 漏洞详情--CNVD-2020-59469   2. 漏洞描述称后台Ba***.cl***.php文件存在任意文件删除,查看cms源码,只有BackdbA ...

  6. 第十章 Kubernetes的CNI网络插件--flannel

    1.简介 1.1前言 Kubernetes设计了网络模型,但却将它的实现讲给了网络插件,CNI网络插件最重要的功能就是实现Pod资源能够跨主机通信 常见的CNI网络插件如下: Flannel: Cac ...

  7. http服务(postman调用方法及反参)

    #region 监听url #region 监听url路径请求 static HttpListener httpobj; private void listeningUrl() { //提供一个简单的 ...

  8. 以TrueType为例谈字形描述

    以TrueType为例谈字形描述 作者:哲思 时间:2022.9.17 邮箱:zhe__si@163.com GitHub:zhe-si (哲思) (github.com) 一.前言 在深入理解&qu ...

  9. 【微服务】- Nacos - 注册中心

    微服务 - 注册中心 - Nacos 生命不息,写作不止 继续踏上学习之路,学之分享笔记 总有一天我也能像各位大佬一样 一个有梦有戏的人 @怒放吧德德 分享学习心得,欢迎指正,大家一起学习成长! 上一 ...

  10. 7. Ceph 高级篇 - RBD块设备回收站、快照、克隆

    文章转载自:https://mp.weixin.qq.com/s?__biz=MzI1MDgwNzQ1MQ==&mid=2247485298&idx=1&sn=b83fda07 ...