1、启动Kafka
./bin/kafka-server-start.sh ./config/server.properties &
2、停止Kafka
./bin/kafka-server-stop.sh
3、创建Topic
# 通过zookepper
./bin/kafka-topics.sh --create --zookeeper 192.168.209.102:2181 --partitions 3 --replication-factor 2 --topic test
# 通过kafka服务
./bin/kafka-topics.sh --create --bootstrap-server 192.168.209.102:9092,192.168.209.102:9093,192.168.209.102:9094 --partitions 3 replication-factor 2 --topic test
4、查看已经创建的Topic信息
# 通过zookepper
./bin/kafka-topics.sh --list --zookeeper 192.168.209.102:2181
# 通过kafka服务
./bin/kafka-topics.sh --list --bootstrap-server 192.168.209.102:9092
5、查看topic详情
# 通过zookepper
./bin/kafka-topics.sh --zookeeper 192.168.209.102:2181 --topic topic3 --describe
# 通过kafka服务
./bin/kafka-topics.sh --bootstrap-server 192.168.209.102:2181 --describe --topic test
6、删除topic
./bin/kafka-topics.sh --zookeeper 192.168.209.102:2181 --topic topic1 --from-beginning--delete
7、发送消息
./bin/kafka-console-producer.sh --broker-list 43.139.86.193:9092 --topic topic1
8、接收消息
./bin/kafka-console-consumer.sh --bootstrap-server 43.139.86.193:9092 --topic topic1 --from-beginning
标签:bin,--,192.168,kafka,topic,sh,常用命令
From: https://www.cnblogs.com/hg-super-man/p/17745887.html