Mac starts local kafka
Open the terminal and execute the following command
1. zkserver start ----start zk
2. Start kafka
2.1 cd /usr/local/Cellar/kafka/ ---to kafka installation directory
2.2 ls ---Check out the kafka version, for example, 0.11.0.1
2.3 cd 0.11.0.1
2.4 cd bin ---- cd /usr/local/Cellar/kafka/0.11.0.1/bin
2.5 ./ kafka-server-start /usr/local/etc/kafka/server.properties---Execute kafka startup script
4. Creating a topic
./ kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic testTopic
5. View the topic created
./ kafka-topics --list --zookeeper localhost:2181
6. Start the production process (testTopic is the topic name) localhost:9092 To be consistent with the configuration pairs in/usr/local/etc/kafka/server.properties, the configuration may be in the form of ip: port pairs.
./ kafka-console-producer --broker-list localhost:9092 --topic testTopic
7. Start the consuming process localhost:9092 To be consistent with the configuration pair in/usr/local/etc/kafka/server.properties, the configuration may be in the form of ip: port pair.
./ kafka-console-consumer --bootstrap-server localhost:9092 --topic testTopic --from-beginning
Note: kafka-related scripts are all in/usr/local/Cellar/kafka/version number (e.g. 0.11.0.1)/bin file