kakfa常用命令

1.kafka依赖于zookeeper,所以先启动zookeeper
进入到kafka目录
bin/zookeeper-server-start.sh config/zookeeper.properties

2.启动kafka
bin/kafka-server-start.sh config/server.properties

3.创建一个topic
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
查看topic的运行状况
bin/kafka-topics.sh --describe --zookeeper localhost:2181 --topic test

4.查看所有topic列表
bin/kafka-topics.sh --list --zookeeper localhost:2181

5.生产者,发送消息到kafka,使用topic test
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test

6.消费者 消费kafka消息
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning

#192.168.100.81:9092 kafka地址
#topic :assistant_message_topic
./kafka-simple-consumer-shell.sh --topic assistant_message_topic --broker-list 192.168.100.81:9092
./kafka-simple-consumer-shell.sh --broker-list brokerhost:9092 --topic myTopic --partition 0 --max-messages 1

查看原文:http://www.baowenwei.com/archives/924

猜你喜欢

转载自blog.csdn.net/piaoslowly/article/details/52205086
今日推荐