写点什么

【kafka】常用命令汇总

  • 2023-02-24
    江西
  • 本文字数:1267 字

    阅读完需:约 4 分钟

1 查询

1.查看所有或者指定 Topic 的信息

查看 Topic 的分区情况 副本情况和 配置情况

## 所有bin/kafka-topics.sh --describe --zookeeper xxxx 
##指定bin/kafka-topics.sh --describe --zookeeper xxxx --topic TOPIC名称
复制代码

输出

[root@ kafka]# bin/kafka-topics.sh --describe --zookeeper xxx.xx.xx.xx --topic SHI_TOPIC3Topic:SHI_TOPIC3 PartitionCount:3 ReplicationFactor:1 Configs:cleanup.policy=compact Topic: SHI_TOPIC3 Partition: 0 Leader: 0 Replicas: 0 Isr: 0 Topic: SHI_TOPIC3 Partition: 1 Leader: 2 Replicas: 2 Isr: 2 Topic: SHI_TOPIC3 Partition: 2 Leader: 1 Replicas: 1 Isr: 1
复制代码

2.列出所有 Topic

## topic列表查询bin/kafka-topics.sh --zookeeper 127.0.0.1:2181 --list
## topic列表查询(支持0.9版本+)bin/kafka-topics.sh --list --bootstrap-server localhost:9092
复制代码

3.新消费者列表查询

## 新消费者列表查询(支持0.9版本+)bin/kafka-consumer-groups.sh --new-consumer --bootstrap-server localhost:9092 --list
## 新消费者列表查询(支持0.10版本+)bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --list
复制代码

输出

[root@]# bin/kafka-consumer-groups.sh --bootstrap-server xxx.xxx.xxx --listNote: This will not show information about old Zookeeper-based consumers.consumer-idconsumer-id1BASE-DEMO
复制代码

4.显示某个消费组的消费详情(0.10.1.0 版本+)

查看某个消费者有多少消费者,消费哪些 Topic; 消费者分别消费哪个分区等等信息;并且消费到的位置 offset

bin/kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group my-group
复制代码

输出

[root@dev5_172_16_10_62 kafka]# bin/kafka-consumer-groups.sh --bootstrap-server  xxxx --describe --group consumer-id7Note: This will not show information about old Zookeeper-based consumers.

TOPIC                          PARTITION  CURRENT-OFFSET  LOG-END-OFFSET  LAG        CONSUMER-ID                                       HOST                           CLIENT-IDSHI_TOPIC3                     0          128             128             0          myClientId7-0-c6568666-b249-491a-a1e2-c3bd85f343c6/172.16.14.37                  myClientId7-0SHI_TOPIC4                     0          0               0               0          myClientId7-0-c6568666-b249-491a-a1e2-c3bd85f343c6/172.16.14.37                  myClientId7-0
复制代码

2TODO

发布于: 刚刚阅读数: 5
用户头像

关注公众号: 石臻臻的杂货铺 获取最新文章 2019-09-06 加入

进高质量滴滴技术交流群,只交流技术不闲聊 加 szzdzhp001 进群 20w字《Kafka运维与实战宝典》PDF下载请关注公众号:石臻臻的杂货铺

评论

发布
暂无评论
【kafka】常用命令汇总_kafka_石臻臻的杂货铺_InfoQ写作社区