1.修改每台服务器config/server.properties
broker.id:唯一,填数字
host.name:填写服务器IP
zookeeper.connect=192.168.1.100:2181,192.168.1.101:2181,192.168.1.103:2181
2.启动
先启动zookeeper服务
bin/zkServer.sh start
再在每台机器上执行Kafka服务
bin/kafka-server-start.sh config/server.properties
3.创建topic
bin/kafka-topics.sh —create —zookeeper localhost:2181 —replication-factor 3 —partitions 1 —topic demo_1
4.查看topic
bin/kafka-topics.sh —list —zookeeper localhost:2181
5.查看详细信息
bin/kafka-topics.sh —describe —zookeeper 192.168.1.100:2181
6.发送消息
bin/kafka-console-producer.sh —broker-list 192.168.1.100:9092 —topic demo_1
7.接收消息
bin/kafka-console-consumer.sh —zookeeper 192.168.1.100:2181 —topic demo_1 —from-beginning