Kafka常用命令记录

一、解压
tar -zxvf kafka_2.11-2.1.0.tgz
mv kafka_2.11-2.1.0 kafka-2.1.0
rm -f kafka_2.11-2.1.0.tgz

二、设置JAVA_HOME
cd /opt/kafka-2.1.0/bin
kafka-run-class.sh中设置JAVA_HOME=/opt/jdk1.8.0_192

三、启动Zookeeper
./zookeeper-server-start.sh ../config/zookeeper.properties &
查看进程 ps -ef|grep zookeeper

四、启动kafka-server
./kafka-server-start.sh ../config/server.properties &
查看进程 ps -ef|grep kafka

五、新建主题

新建一个主题test
./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

六、列出主题
./kafka-topics.sh --list --zookeeper localhost:2181

七、发送消息

发送消息到主题test
./kafka-console-producer.sh --broker-list localhost:9092 --topic test

八、接收消息

从主题test接收消息
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning

九、查看主题

查看主题test信息
./kafka-topics.sh --describe --zookeeper localhost:2181 --topic test

猜你喜欢

转载自blog.csdn.net/zhigang0529/article/details/85230125
今日推荐