使用docker-compose部署并运行kafka与kafka-manager
zookeeper 请参考zookeeper 部署文档
- 创建kafka-docker目录
mkdir kafka-docker & cd kafka-docker
- 创建docker-compose.yml
version: '2'
services:
kafka:
image: 192.168.24.173/wurstmeister/kafka:2.11-1.0.2
restart: always
container_name: kafka
network_mode: host
environment:
KAFKA_BROKER_ID: ${KAFKA_BROKER_ID}
KAFKA_ADVERTISED_PORT: 9092
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://${KAFKA_BROKER_IP}:9092
KAFKA_LISTENERS: PLAINTEXT://${KAFKA_BROKER_IP}:9092
KAFKA_ZOOKEEPER_CONNECT: 192.168.24.173:2181,192.168.24.178:2181,192.168.24.179:2181
volumes:
- /var/run/docker.sock:/var/run/docker.sock
kafka-manager:
image: 192.168.24.173/sheepkiller/kafka-manager:1.3.1.8
restart: always
container_name: kafka-manager
network_mode: host
environment:
ZK_HOSTS: 192.168.24.173:2181,192.168.24.178:2181,192.168.24.179:2181
APPLICATION_SECRET: letmein
- 运行docker-compose
export KAFKA_BROKER_ID=1
export KAFKA_BROKER_IP=192.168.24.173
docker-compose up
若运行成功,则使用
docker-compose up -d
转为后台运行
- 停止容器
docker-compose stop
- 删除容器
docker-compose rm -f
- 成功后Web访问9000端口,发现并没有显示集群,还需要手动添加集群(官方文档)
参考文档
docker下部署kafka集群(多个broker+多个zookeeper)
Kafka集群部署(Docker容器的方式)
docker版Kafka集群
【KAFKA】通过docker部署kafka集群
网友评论