1.创建自定义的topic
在bin目录下执行:
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
注:副本数量要小于等于节点数量
2.查看所有的topic
kafka-topics.sh --list --zookeeper hostname:2181
3.启动producer
kafka-console-producer.sh --broker-list hostname:9092 --topic test
4.启动consumer
kafka-console-consumer.sh --bootstrap-server hostname:9092 --topic test --from-beginning
5.启动kafka
kafka-server-start.sh -daemon /opt/kafka_2.12-2.3.1/config/server.properties
6.删除topic指令:
进入bin目录,执行:
kafka-topics.sh --delete --zookeeper hadoop01:2181 --topic enbook