Kafka 命令总结

编程入门 行业动态 更新时间:2024-10-27 00:28:10

Kafka <a href=https://www.elefans.com/category/jswz/34/1771323.html style=命令总结"/>

Kafka 命令总结

//列出所有的topic
kafka-topics --zookeeper localhost:2181 --list
//查看指定topic的分区、副本情况
kafka-topics --zookeeper localhost:2181 --topic test_topic --describe

//消费某个topic,可以从头消费,也可以指定分区或带过滤条件消费
kafka-console-consumer --bootstrap-server localhost:9092 --topic test_topic --from-beginning 
kafka-console-consumer --bootstrap-server localhost:9092 --topic test_topic --partition 2 | grep "test"

//在某个topic生成数据
kafka-console-producer --broker-list localhost:9092 --topic test_topic

//创建topic,可以设定分区、副本,也可以配置一些内容
kafka-topics --create --zookeeper localhost:2181 --replication-factor 2 --partitions 2 --topic test_topic --config message.timestamp.type=CreateTime
//修改某个topic的分区数或配置信息
kafka-topics --alter --zookeeper localhost:2181 --topic test_topic --partitions 4 
kafka-topics --zookeeper localhost:2181 --alter --topic test_topic --config max.partition.fetch.bytes=5252880
//删除某个topic
kafka-topics --zookeeper localhost:2181 --delete --topic test_topic

//获取Kafka每个分区最新Offset的几种方法
kafka-run-class kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic test_topic

//消费组
kafka-consumer-groups --bootstrap-server localhost:9092 --list  //列出当前集群中所有的消费组名称
kafka-consumer-groups --bootstrap-server localhost:9092 --group test_group --describe  //展示消费组test_group的详细信息
kafka-consumer-groups --bootstrap-server localhost:9092 --describe --group test_group --state //展示消费组test_group状态
kafka-consumer-groups --bootstrap-server localhost:9092 --describe --group test_group --members --verbose//展示消费组test_group成员
kafka-consumer-groups --bootstrap-server localhost:9092 --group test_group --delete//删除消费组test_group

更多推荐

Kafka 命令总结

本文发布于:2024-03-05 03:35:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1711214.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:命令   Kafka

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!