启动和配置kafka
#0 依赖zookeeper
#1. 解压包
tar zxvf kafka_2.12-2.8.0.tgz
# 2、修改配置
vim kafka_2.12-2.8.0/config/server.properties
broker.id=0
listeners=PLAINTEXT://192.168.151.9:9092
zookeeper.connect=localhost:2181/kafka
log.dirs=/tmp/kafka-logs
#3.启动
bin/kafka-server-start.sh -daemon bin/config/server.properties
#4.测试 (master为zookeeper所在服务器的host)
#创建topic
bin/kafka-topics.sh --create --zookeeper master:2181 --replication-factor 1 --partitions 1 --topic topic1
#查看创建了多少个
bin/kafka-topics.sh --list --zookeeper master:2181
#生产者发送消息
bin/kafka-console-producer.sh --broker-list app:9092 --topic topic1
#查看消费者接受到的消息
bin/kafka-console-consumer.sh --bootstrap-server app:9092 --topic topic1 --from-beginning