首先启动zookeeper集群
start_zk.sh
然后进入kafka_2.11-2.0.0文件夹,开启kafka
bin/kafka-server-start.sh config/server.properties
另开一个hadoop01窗口
创建会话
kafka-topics.sh --create \
--topic itcasttopic \
--partitions 3 \
--replication-factor 1 \
--zookeeper hadoop01:2181,hadoop02:2181,hadoop03:2181
创建生产者
kafka-console-producer.sh \
--broker-list hadoop01:9092,hadoop02:9092,hadoop03:9092 \
--topic itcasttopic
在hadoop02创建消费者
kafka-console-consumer.sh \
--from-beginning --topic itcasttopic \
--bootstrap-server hadoop01:9092,hadoop02:9092,hadoop03:9092
此时生产者发送消息,消费者可以接收得到
查看所有会话
kafka-topics.sh --list \
--zookeeper hadoop01:2181,hadoop02:2181,hadoop03:2181
删除会话
kafka-topics.sh --delete \
--zookeeper hadoop01:2181,hadoop02:2181,hadoop03:2181 \
--topic itcasttopic