kafka 集群安装

修改每台服务器的config/server.properties

broker.id:  唯一,填数字,本文中分别为101,102,103

host.name: 填服务器IP
zookeeper.connect=hadoop1:2181,hadoop2:2181,hadoop3:2181
先启动zookeeper服务: zkServer.sh start
再在每台机器上执行: bin/kafka-server-start.sh config/server.properties 

创建topic:
h  kafka-create-topic.sh --zookeeper hadoop1:2181,hadoop2:2181,hadoop3:2181  --topic mykafka

显示Topic:mykafka
sh  kafka-list-topic.sh  --zookeeper  hadoop1:2181,hadoop2:2181,hadoop3:2181


发送消息:

sh  kafka-console-producer.sh --broker-list hadoop2:9092 --topic mykafka

23423
接收消息:
sh   kafka-console-consumer.sh --zookeeper hadoop1:2181,hadoop2:2181,hadoop3:2181 --topic mykafka --from-beginning

23423







你可能感兴趣的:(kafka 集群安装)