备注
操作环境: centos7 ,docker环境
安装zookeeper
docker pull zookeeper:3.7.0
docker run --name zookeeper -p 2181:2181 --restart always -d zookeeper:3.7.0
firewall-cmd --permanent --zone=public --add-port=2181/tcp
firewall-cmd --permanent --zone=public --add-port=9092/tcp
firewall-cmd --reload
firewall-cmd --list-all
zk工具
prettyZoo
安装kafka
docker run -d --name kafka
-p 9092:9092
-e KAFKA_BROKER_ID=0
-e KAFKA_ZOOKEEPER_CONNECT=47.103.64.29:2181
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://47.103.64.29:9092
-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 wurstmeister/kafka
47.103.64.29 是外网ip地址。
进入kafka容器
docker exec -it 容器id bash
cd /opt/kafka_2.13-2.8.1/bin
生成消息
kafka-topics.sh --create --zookeeper 47.103.64.29:2181 --replication-factor 1 --partitions 1 --topic kafkatest
消费消息
kafka-console-consumer.sh --bootstrap-server 47.103.64.29:9092 --topic kafkatest --from-beginning
kafka消息查看工具
Kafka Tool
https://www.cnblogs.com/miracle-luna/p/11299345.html
本文完!!