mac安装 参考
1. brew install kafka
安装目录:/usr/local/Cellar/kafka/0.10.2.0
安装配置文件位置:
/usr/local/etc/kafka/server.properties
/usr/local/etc/kafka/zookeeper.properties
2.启动 zookeeper
./bin/zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties &
3.启动 kafka
./bin/kafka-server-start /usr/local/etc/kafka/server.properties &
4.创建topic
让我们使用单个分区和只有一个副本创建一个名为“test”的主题
./bin/kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
5.查看创建的topic
./bin/kafka-topics --list --zookeeper localhost:2181
6.发消息
./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
7.消费消息
./bin/kafka-console-consumer --bootstrap-server localhost:9092 --topic test --from-beginning