一、mac安裝kafka:brew install kafkabootstrap
二、啓動zookeeper:zookeeper-server-start /usr/local/etc/kafka/zookeeper.propertiesserver
三、啓動kafka:kafka-server-start /usr/local/etc/kafka/server.properties (kafka-server-start須要設置環境變量才能直接使用,若是報錯,先執行kafka-server-stop /usr/local/etc/kafka/server.properties便可)kafka
四、建立topic:kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 3 --topic kafka-topicit
五、查看topic列表:kafka-topics --list --zookeeper localhost:2181io
六、生產者命令使用:kafka-console-producer --broker-list localhost:9092 --topic kafka-topicconsole
七、消費者命令使用:kafka-console-consumer --bootstrap-server localhost:9092 --topic kafka-topic --from-beginning(執行成功後,生產者產生的消息都能在消費者這裏出現了)變量