1、使用brew install命令安装Kafka
代码语言:javascript复制$ brew install kafka
- 安装过程将依赖安装 zookeeper
- 软件位置 /usr/local/Cellar/zookeeper /usr/local/Cellar/kafka
- 配置文件位置 /usr/local/etc/kafka/zookeeper.properties /usr/local/etc/kafka/server.properties
备注:后续操作均需进入 /usr/local/Cellar/kafka/2.0.0/bin 目录下。
2. 启动zookeeper zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties
3. 启动kafka服务 kafka-server-start /usr/local/etc/kafka/server.properties 4. 创建topic kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test1 5. 查看创建的topic kafka-topics --list --zookeeper localhost:2181 6. 生产数据 kafka-console-producer --broker-list localhost:9092 --topic test1
7. 消费数据 kafka-console-consumer --bootstrap-server 127.0.0.1:9092 --topic test1 --from-beginning
备注:–from-beginning 将从第一个消息还是接收