使用brew安装
安装完之后,安装目录为:# kafka安装目录
/usr/local/Cellar/kafka/2.2.1
# 配置文件目录
/usr/local/etc/kafka/如果需要修改配置,可以进入对应目录,修改配置文件就好
启动kafka是基于zookeeper的,启动kafka之前,需要先启动zookeeperzkServer start启动后,查看启动是否成功ps aux|grep zookeeper启动kafkakafka-server-start /usr/local/etc/kafka/server.properties &查看启动是否成功ps aux | grep kafka
创建一个topic# 命令行参数含义,后续补充,当前页不是很清楚,约莫能猜出个大概
kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic ZongMan
查看topic列表kafka-topics --list --zookeeper localhost:2181
创建一个生产者kafka-console-producer --broker-list localhost:9092 --topic ZongMan
创建二个消费者kafka-console-consumer --bootstrap-server localhost:9092 --topic test --from-beginning
服务的关闭服务关闭的顺序是先kafka,然后zookeeper# 关闭kafka
/usr/local/Cellar/kafka/2.2.1/bin/kafka-server-stop
#关闭zookeeper
/usr/local/Cellar/kafka/2.2.1/bin/zookeeper-server-stop