Mac 中使用Kafka

78 阅读1分钟

Windows参考链接:www.cnblogs.com/Shineloner/…

下载地址:kafka.apache.org/downloads

1.启动zookeeper并指定启动的配置文件

#  Mac
./bin/zookeeper-server-start.sh config/zookeeper.properties

2.启动Kafka并指定启动的配置文件

./bin/kafka-server-start.sh config/server.properties

3.创建topic

# testInfoTopic 名称(自定义)
./bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic testInfoTopic --partitions 2 --replication-factor 1

4.查看topic

./bin/kafka-topics.sh --list --bootstrap-server localhost:9092

5.生产数据

./bin/kafka-console-producer.sh --broker-list localhost:9092 --topic testInfoTopic

6.消费数据

./bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic testInfoTopic

7.关闭zookeeper

 ./bin/kafka-server-stop.sh

8.关闭kafka

 ./bin/zookeeper-server-stop.sh