安装
brew install kafka
如果缺少JDK8依赖,或安装了JDK10,则需要先通过brew cask
插件安装JDK8:
brew cask install java8
安装位置
/usr/local/Cellar/zookeeper
/usr/local/Cellar/kafka
配置文件位置
/usr/local/etc/kafka/server.properties
/usr/local/etc/kafka/zookeeper.properties
启动
直接启动:
zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties &
kafka-server-start /usr/local/etc/kafka/server.properties &
或通过brew services
插件启动
brew services start zookeeper
brew services start kafka
创建topic
kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
查看创建的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
附:brew services说明
https://github.com/Homebrew/homebrew-services