• 安装(会自动依赖安装zookeeper)
brew install kafka 
  • 启动zookeeper
cd /usr/local/Cellar/kafka/2.1.1/bin/
./zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties &
  • 启动kafka
./kafka-server-start /usr/local/etc/kafka/server.properties &
  • 查看配置文件
cd /usr/local/etc/kafka/
cd /usr/local/etc/zookeeper/
  • 创建topic
kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic sunday

  • 查看topic列表
kafka-topics --list --zookeeper localhost:2181

  • 发送消息
kafka-console-producer --broker-list localhost:9092 --topic test

  • 接收消息
kafka-console-consumer --bootstrap-server localhost:9092 --topic test --from-beginning

版权声明:本文为hu-hugh原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/hu-hugh/p/macos-an-zhuang-shi-yongkafka.html