docker 部署kafka集群

在部署kafka集权之前必须要先部署好zookeeper集权,kafka注册在zookeeper集群中,zookeeper集群可参看:

docker 安装zookeeper集群

 

涉及到的虚拟主机:

192.168.1.104 node1

192.168.1.105 node2

 

创建本地目录

mkdir -p /docker/kafka/logs

创建容器

第一个节点上:

docker run -d --net host --restart unless-stopped -p 9092:9092 \-e CLUSTER_NAME=KAFKA  \-e KAFKA_ADVERTISED_HOST_NAME=172.19.184.201 \-e KAFKA_ADVERTISED_PORT=9092 \-e KAFKA_ZOOKEEPER_CONNECT=172.19.184.201:2181,172.19.184.202:2181 \-e KAFKA_HOST_NAME=172.19.184.201 \-e KAFKA_BROKER_ID=1 \-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 \-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://47.103.34.188:9092 \-e KAFKA_DELETE_TOPIC_ENABLE=true \-v /docker/kafka/logs:/kafka \--name kafka1 wurstmeister/kafka

第二个节点:

docker run -d --net host --restart unless-stopped -p 9092:9092 \-e CLUSTER_NAME=KAFKA  \-e KAFKA_ADVERTISED_HOST_NAME=172.19.184.202 \-e KAFKA_ADVERTISED_PORT=9092 \-e KAFKA_ZOOKEEPER_CONNECT=172.19.184.202:2181,172.19.184.201:2181 \-e KAFKA_HOST_NAME=172.19.184.202 \-e KAFKA_BROKER_ID=2 \-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 \-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://47.103.35.68:9092 \-e KAFKA_DELETE_TOPIC_ENABLE=true \-v /docker/kafka/logs:/kafka \--name kafka1 wurstmeister/kafka

 

部署查看集群工具

docker run -itd --restart=always --name=kafka-manager -p 9000:9000 -e ZK_HOSTS="172.19.184.201:2181" sheepkiller/kafka-manager:alpine

 

你可能感兴趣的:(kafka)