docker install zk & kafka

docker run -d --name zookeeper -p 2181:2181 -t wurstmeister/zookeeper

docker run -d --name kafka \
-p 9092:9092 \
-e KAFKA_BROKER_ID=0 \
-e KAFKA_ZOOKEEPER_CONNECT=192.168.0.106:2181 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.0.106:9092 \
-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 -t wurstmeister/kafka:latest

docker exec -ti kafka /bin/bash

 

1.CREATE A TOPIC TO STORE YOUR EVENTS
bin/kafka-topics.sh --create --topic quickstart-events --bootstrap-server localhost:9092


2. view topic detail
bin/kafka-topics.sh --describe --topic quickstart-events --bootstrap-server localhost:9092


3.WRITE SOME EVENTS INTO THE TOPIC
bin/kafka-console-producer.sh --topic quickstart-events --bootstrap-server localhost:9092
This is my first event
This is my second event


4. READ THE EVENTS
bin/kafka-console-consumer.sh --topic quickstart-events --from-beginning --bootstrap-server localhost:9092
This is my first event
This is my second event

 

 

posted @ 2022-06-05 17:34  Alamps  阅读(40)  评论(0编辑  收藏  举报