1、安装kafka
brew install kafka
2、启动zookeeper
zkServer start
3、启动kafka
brew services restart kafka
4、创建topic
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic testTopic
5、产生数据
kafka-console-producer.sh --broker-list localhost:9092 --topic testTopic
输入数据:
hello
aaaaaaa
test
!!!!!
6、消费数据
新建一个终端:
kafka-console-consumer.sh --zookeeper localhost:2181 --topic testTopic --from-beginning