获取zookeeper
docker pull zookeeper
获取kafka镜像
docker pull wurstmeister/kafka
创建运行zookeeper容器
docker run --name zookeeper-local -p 2181:2181 -p 2888:2888 -p 3888:3888 -v /Users/liangtianyu/work/docker/zookeeper/data:/data -v /Users/liangtianyu/work/docker/zookeeper/log:/datalog --restart always -d zookeeper
创建运行kafka容器
docker run --name kafka-local -p 9092:9092 --link zookeeper-local -e KAFKA_ZOOKEEPER_CONNECT=zookeeper-local:2181 -e KAFKA_ADVERTISED_HOST_NAME=localhost -e KAFKA_ADVERTISED_PORT=9092 --restart always -d wurstmeister/kafka
进入容器创建
docker exec -it kafka-local /bin/bash
创建topic
./opt/kafka/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 2 --topic log-service-topic
查看topic
./opt/kafka/bin/kafka-topics.sh --list --zookeeper zookeeper-local
网友评论