Docker 里面运行 Kafka

kafka使用到了zookeeper, 需要先启动zookeeper 查看我关于zookeeper[https://mp.csdn.net/postedit/84646084]

docker run -d -p 12181:2181 -v /var/local/zookeeper/data:/data -v /var/local/zookeeper/datalog:/datalog -v /var/local/zookeeper/conf/:/conf -p 12888:2888 -p 13888:3888 --name zookeeper docker.io/zookeeper

 

然后启动 kafka容器

docker run -d --name kafka \

-p 9092:9092 \

--link 192.168.1.10:2181 \

-e HOST_IP=192.168.1.10 \

-e KAFKA_ADVERTISED_PORT=9092 \

-e KAFKA_BROKER_ID=0 \

-e KAFKA_ZOOKEEPER_CONNECT=192.168.1.10:12181 \

-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.1.10:9092 \

-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 -t wurstmeister/kafka

 

# kafka集群 broker 0

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

# kafka集群 broker 1

docker run -d --name kafka -p 19092:9092 -e KAFKA_BROKER_ID=0 -e KAFKA_ZOOKEEPER_CONNECT=192.168.1.10:12181 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.1.10:19092 -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:19092 -t wurstmeister/kafka

你可能感兴趣的:(docker)