安装(mac版)
1. 安装命令: brew install kafka
出现: zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties & kafka-server-start /usr/local/etc/kafka/server.properties
表示:安装成功
2. 首先要启动zookeeper(博主之前只启动了kafka,在创建topic时就报错了)
brew services start zookeeper
3. 启动kafka
brew services start kafka
启动成功后。。。。
创建topic:test(可自己命名)
kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
结果:Created topic test.
然后
查看自己的topic-list
kafka-topics --list --zookeeper localhost:2181
结果:test
进行消费者与生产者测试
进入到bin目录
cd /usr/local/Cellar/kafka/2.2.0/libexec/bin/
创建生产者
kafka-console-producer -broker-list localhost:9092 -topic test
创建消费者
kafka-console-consumer -bootstrap-server localhost:9092 -topic test -from-beginning