1蔓榄、安裝kafka
brew install kafka
2垫蛆、啟動zookeeper
zkServer start
3呵哨、啟動kafka
brew services restart kafka
4泉坐、創(chuàng)建topic
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic testTopic
5、產(chǎn)生數(shù)據(jù)
kafka-console-producer.sh --broker-list localhost:9092 --topic testTopic
輸入數(shù)據(jù):
hello
aaaaaaa
test
!8然;耷健!肴茄!
6晌畅、消費數(shù)據(jù)
新建一個終端:
kafka-console-consumer.sh --zookeeper localhost:2181 --topic testTopic --from-beginning