让你直呼好用的几个常见Kafka命令

本文汇总了Kafka中常用的命令,包括生产者消息发送、消费者消息接收、消费组积压情况查看、主题列表查看及详情、重置offset及根据时间戳获取offset等操作。同时还推荐了一款图形化工具OffsetExplorer,方便进行offset管理和监控。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

生产者:

./bin/kafka-console-producer.sh --broker-list 192.168.7.130:9092 --topic test

消费者:

./bin/kafka-console-consumer.sh --bootstrap-server 192.168.7.130:9092 --topic test_topic --property print.timestamp=true

消费组积压查看:

./bin/kafka-consumer-groups.sh --bootstrap-server 192.168.7.130:9092 --describe --group test_group

topic列表查看:

./bin/kafka-topics.sh --zookeeper 192.168.7.130:2181 -list | grep test_topic

topic详情查看:

./bin/kafka-topics.sh --zookeeper 192.168.7.130:2181 --topic test_topic --describe

重置offset:

./bin/kafka-consumer-groups.sh --bootstrap-server 192.168.7.130:9092 --group test_group --reset-offsets --to-offset 1000 --topic test_out --execute

根据时间戳获取offset:

./bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list 192.168.5.16:9092 --topic test_topic --time 1651212840000

图形化工具推荐: Kafka tool (新版名字:Offset Explorer)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值