kafka的常用命令

今天主要来介绍一些kafka的常用命令,记录一下,便于平时使用:

1.kafka启动:  ./kafka-server-start.sh ../config/server.properties &

2.创建topic:  ./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic tes

3.查看kafka的topic:./kafka-topics.sh --zookeeper master:2181 --list

4.查看kafka某个topic下partition信息: ./kafka-topics.sh --describe --zookeeper master:2181 --topic test-topic

5.查看kafka的指定topic:  ./kafka-topics.sh --zookeeper master:2181 --describe --topic yq20171220

6.控制台向kafka生产数据:  ./kafka-console-producer.sh --broker-list master:9092 --topic jason_20180519

7.控制台消费kafka的数据:  ./kafka-console-consumer.sh  --zookeeper storm1:2181  --topic jason_20180519 --from-beginning

8.查看topic下某分区偏移量的最小值: ./kafka-run-class.sh kafka.tools.GetOffsetShell --topic test-topic  --time -1 --broker-list master:9092 --partitions 0

9./kafka-topics.sh --alter --topic jason_20180519 --zookeeper 10.200.10.24:2181,10.200.10.26:2181,10.200.10.29:2181 --partitions 5  

10.删除topic,慎用,只会删除zookeeper中的元数据,消息文件须手动删除:  ./kafka-run-class.sh kafka.admin.DeleteTopicCommand --zookeeper master:2181 --topic yq20171220

11.彻底删除topic: rmr /brokers/topics/【topic name】即可

 如果有写的不对的地方,欢迎大家指正,如果有什么疑问,可以加QQ群:340297350,谢谢

猜你喜欢

转载自blog.csdn.net/xianpanjia4616/article/details/81139314
今日推荐