赞
踩
docker network create kafkacluster_default
docker-compose-zookeeper-cluster.yml
version: '3.5' networks: kafkacluster_default: external: true services: zoo1: image: zookeeper restart: unless-stopped hostname: zoo1 container_name: zoo1 ports: - 2182:2181 environment: ZOO_MY_ID: 1 ZOO_SERVERS: server.1=0.0.0.0:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=zoo3:2888:3888;2181 volumes: - /usr/local/zookeeper/zoo1/data:/data - /usr/local/zookeeper/zoo1/datalog:/datalog networks: - kafkacluster_default zoo2: image: zookeeper restart: unless-stopped hostname: zoo2 container_name: zoo2 ports: - 2183:2181 environment: ZOO_MY_ID: 2 ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=0.0.0.0:2888:3888;2181 server.3=zoo3:2888:3888;2181 volumes: - /usr/local/zookeeper/zoo2/data:/data - /usr/local/zookeeper/zoo2/datalog:/datalog networks: - kafkacluster_default zoo3: image: zookeeper restart: unless-stopped hostname: zoo3 container_name: zoo3 ports: - 2184:2181 environment: ZOO_MY_ID: 3 ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=0.0.0.0:2888:3888;2181 volumes: - /usr/local/zookeeper/zoo3/data:/data - /usr/local/zookeeper/zoo3/datalog:/datalog networks: - kafkacluster_default
启动zookeeper集群
docker-compose -f docker-compose-zookeeper-cluster.yml up -d
docker-compose-kafka-cluster.yml
version: '3.5' networks: kafkacluster_default: external: true services: kafka1: image: wurstmeister/kafka restart: unless-stopped container_name: kafka1 ports: - "9093:9092" external_links: - zoo1 - zoo2 - zoo3 environment: KAFKA_BROKER_ID: 1 KAFKA_ADVERTISED_HOST_NAME: 192.168.1.111 ## 修改:宿主机IP
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。