version: '2.2'
services:
zookeeper:
image: zookeeper:3.6.3
ports:
- "2181:2181"
restart: always
kafka1:
image: bitnami/kafka:2.1.0
depends_on: [ zookeeper ]
container_name: kafka1
ports:
- "9091:9091"
environment:
HOSTNAME: kafka1
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka1:9091
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9091
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: "yes"
extra_hosts:
kafka1: 10.21.214.66
kafka2:
image: bitnami/kafka:2.1.0
depends_on: [ zookeeper ]
container_name: kafka2
ports:
- "9092:9092"
environment:
HOSTNAME: kafka2
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka2:9092
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: "yes"
extra_hosts:
kafka2: 10.21.214.66
kafka3:
image: bitnami/kafka:2.1.0
depends_on: [ zookeeper ]
container_name: kafka3
ports:
- "9093:9093"
environment:
HOSTNAME: kafka3
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka3:9093
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9093
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
ALLOW_PLAINTEXT_LISTENER: "yes"
extra_hosts:
kafka3: 10.21.214.66
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 其中zookeeper会转化成zookeeper的ip
kafka1: 10.21.214.66 其中10.21.214.66 填写宿主机ip
文章来源地址https://www.toymoban.com/news/detail-826412.html
文章来源:https://www.toymoban.com/news/detail-826412.html
到了这里,关于docker容器单机部署zookeeper+kafka集群的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!