1. 安装zookeeper
brew install zookeeper
默认安装位置
启动文件: /usr/local/Cellar/zookeeper/3.4.10/bin/
配置文件: /usr/local/etc/zookeeper/
2. 启动zookeeper 服务
nohup zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties &
3. 安装kafka
brew install kafka
4. 修改Kafka服务配置文件
修改配置文件 /usr/local/etc/kafka/server.properties
解除注释: listeners=PLAINTEXT://localhost:9092
5. 启动Kafka服务
nohup kafka-server-start /usr/local/etc/kafka/server.properties &
6. 新建topic
kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic topic_a
查看已有主题list
kafka-topics --list --zookeeper localhost:2181
修改分区数
kafka-topics --zookeeper localhost:2181 --alter --topic topic_a --partitions 2
7. 创建生产者
kafka-console-producer --topic topic_a --broker-list localhost:9092
8. 创建消费者
kafka-console-consumer --bootstrap-server localhost:9092 -topic topic_a