进入kafka安装bin目录下
[root@cs01]:cd /usr/local/kafka/bin
查看topic列表
[root@cs01]:./kafka-topics.sh --list --zookeeper cs01:2181,cs02:2181,cs03:2181
创建topic(replication-factor:副本 | partitions :主题分区数 )
[root@cs01]:./kafka-topics.sh --create --zookeeper cs01:2181,cs02:2181,cs03:2181 --replication-factor 3 --partitions 3 --topic test
查看topic详细信息
[root@cs01]:./kafka-topics.sh --zookeeper cs01:2181,cs02:2181,cs03:2181 --describe --topic test
生产topic消息
[root@cs01]:./kafka-console-producer.sh --broker-list cs01:9092,cs02:9092,cs03:9092 --topic test
消费topic消息
[root@cs01]:./kafka-console-consumer.sh --bootstrap-server cs01:9092,cs02:9092,cs03:9092 --topic test --from-beginning
删除topic
[root@cs01]:./kafka-topics.sh --zookeeper cs01:2181,cs02:2181,cs03:2181 --delete --topic test
启动服务
[root@cs01] : ./kafka-server-start.sh -daemon …/config/server.properties
停止服务
[root@cs01] : ./kafka-server-stop.sh …/config/server.properties