启动Zookeeper
List-1
docker run -d --name zookeeper -p 2181:2181 wurstmeister/zookeeper:latest
启动Kafka,将如下的俩个172.26.111.240换为自己的IP地址
List-2
docker run -d --name kafka -p 9092:9092 -e KAFKA_BROKER_ID=0 -e KAFKA_ZOOKEEPER_CONNECT=172.26.111.240:2181 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://172.26.111.240:9092 -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 -t wurstmeister/kafka
创建生产者,看https://www.cnblogs.com/xiaodf/p/6093261.html
创建topic,如下
List-3
kafka-console-producer.sh --broker-list localhost:9092 --topic my-topic
/bin/kafka-topics.sh --list --zookeeper localhost:2181
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic my-topicbin/kafka-console-consumer.sh --broker-list localhost:9092 --topic my-topic
kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic topic1
Reference:
- https://blog.csdn.net/lblblblblzdx/article/details/80548294