kafka之常用命令

kafka常用命令包括创建topic,查看topic列表等。

功能 命令 备注
创建topic kafka_home/bin/kafka-topics.sh --create -zookeeper node1:2181 --topic test --replication-factor 1 --partitions 1 zookeeper地址查看kafka_home/config/server.properties的zookeeper.connect参数
查看Topic列表 kafka_home/bin/kafka-topics.sh --list -zookeeper node1:2181
消费Topic消息 kafka_home/bin/kafka-console-consumer.sh --zookeeper node1:2181 --topic test --from-beginning from-beginning从当前topic中offset有效最小值开始读取
生产topic消息 kafka_home/bin/kafka-console-producer.sh --broker-list node6:9981 --topic test kafka使用的broker-list地址查看kafka_home/config/server.properties的advertised.listeners参数
查看offset的有效最小值 kafka_home/bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list node6:9981 -topic test–time -2 kafka中可设置log的过期时间,到了过期时间,便会删除,因此最小的offset不是为0,是会持续变化
查看offset的有效最大值 kafka_home/bin/kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list node6:9981 -topic test–time -1
查看每个partition的消费性能 kafka_home/bin/kafka-consumer-perf-test.sh --broker-list node6:9981 --topic test --group test --messages 100000 --show-detailed-stats 主要看每个partition的消费性能是否正常
查看topic的offset,logsize和lag kafka_home/bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --group test --topic test –zookeeper node1:2181 查看在当前groupid下,topic的使用情况

猜你喜欢

转载自blog.csdn.net/dingding_ting/article/details/84952497
今日推荐