安装
如果缺少JDK8依赖,或安装了JDK10,则需要先通过brew cask
插件安装JDK8:
安装位置
1 2
| /usr/local/Cellar/zookeeper /usr/local/Cellar/kafka
|
配置文件位置
1 2
| /usr/local/etc/kafka/server.properties /usr/local/etc/kafka/zookeeper.properties
|
启动
直接启动:
1 2
| zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties & kafka-server-start /usr/local/etc/kafka/server.properties &
|
或通过brew services
插件启动
1 2
| brew services start zookeeper brew services start kafka
|
创建topic
1
| kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
|
查看创建的topic
1
| kafka-topics.sh --list --zookeeper localhost:2181
|
发送一些消息
1
| kafka-console-producer.sh --broker-list localhost:9092 --topic test
|
消费消息
1
| kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
|
附:brew services说明
https://github.com/Homebrew/homebrew-services
附:brew cask说明
https://caskroom.github.io