docker run -d --restart=always --name zookeeper --volume /etc/localtime:/etc/localtime -p 6181:2181 -p 2888:2888 -p 3888:3888 -t zookeeper
docker run -d --name kafka --publish 19092:9092 \
--link zookeeper \
--env KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 \
--env KAFKA_ADVERTISED_HOST_NAME=192.168.1.22 \
--env KAFKA_ADVERTISED_PORT=19092 --restart=always \
--volume /etc/localtime:/etc/localtime \
wurstmeister/kafka
docker run -d --name dubbo-admin --link zookeeper -p 9600:8080 -e DUBBO_REGISTRY=”zookeeper:\/\/zookeeper:2181” --restart=always riveryang/dubbo-admin
docker目录
cd opt/kafka_2.11-0.10.1.1/
创建一个主题
bin/kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic mykafka
运行一个消息生产者,指定topic为刚刚创建的主题
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic mykafka
运行一个消费者,指定同样的主题
bin/kafka-console-consumer.sh --zookeeper zookeeper:2181 --topic mykafka --from-beginning