kafka的一些常用命令

 

 

 

启动zookeeper

bin/zookeeper-server-start.sh config/zookeeper.properties &

启动kafka

bin/kafka-server-start.sh config/server.properties &

停止kafka
bin/kafka-server-stop.sh

停止zookeeper
bin/zookeeper-server-stop.sh

 

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

展示topic
bin/kafka-topics.sh --list --zookeeper localhost:2181

描述topic
bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic my-replicated-topic

生产者:
bin/kafka-console-producer.sh --broker-list 130.51.23.95:9092 --topic my-replicated-topic

消费者:
bin/kafka-console-consumer.sh --zookeeper 130.51.23.95:2181 --topic test --from-beginnin

查看条数
./kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list localhost:9092 --topic my-topic --time -1

删除话题
/kafka-topics.sh --zookeeper localhost:2181 --delete --topic my-topic

posted on 2017-12-11 15:11  alex.shu  阅读(1117)  评论(0编辑  收藏  举报

导航