docker-compose跨机器部署kafka集群(包含zookeeper集群搭建) 第一版本

  1. 需要的镜像:
    zookeeper:3.5.5
    wurstmeister/kafka:2.12-2.2.1
    kafkamanager/kafka-manager:1.3.3.23
  2. ip规划:
    zookeeper集群:
    10.100.46.3
    10.100.46.5
    10.100.46.6
    kafka集群:
    10.100.46.7
    10.100.46.9
    kafka manager :
    10.100.46.7
  3. docker-compose文件:
    zookeeper集群:
    10.100.46.3:
    version: '2'
    services:
     zookeeper-3:
      image: zookeeper
      container_name: zookeeper-3
      restart: always
      network_mode: "host"
      ports:
        - 2181:2181
        - 2888:2888
        - 3888:3888
      volumes:
        - "/data/zookeeper/data:/data"
        - "/data/zookeeper/datalog:/datalog"
        - "/data/zookeeper/log:/log"
      environment:
        ZOO_MY_ID: 3
        ZOO_SERVERS: server.3=10.100.46.3:2888:3888;2181 server.5=10.100.46.5:2888:3888;2181 server.6=10.100.46.6:2888:3888;2181
    
    10.100.46.5
     version: '2'
     services:
      zookeeper-5:
       image: zookeeper
       container_name: zookeeper-5
       restart: always
       network_mode: "host"
       ports:
         - 2181:2181
         - 2888:2888
         - 3888:3888
       volumes:
         - "/data/zookeeper/data:/data"
         - "/data/zookeeper/datalog:/datalog"
         - "/data/zookeeper/log:/log"
       environment:
         ZOO_MY_ID: 5
         ZOO_SERVERS: server.3=10.100.46.3:2888:3888;2181 server.5=10.100.46.5:2888:3888;2181 server.6=10.100.46.6:2888:3888;2181
    
    10.100.46.6
    version: '2'
    services:
      zookeeper-6:
       image: zookeeper
       container_name: zookeeper-6
       restart: always
       network_mode: "host"
       ports:
         - 2181:2181
         - 2888:2888
         - 3888:3888
       volumes:
         - "/data/zookeeper/data:/data"
         - "/data/zookeeper/datalog:/datalog"
         - "/data/zookeeper/log:/log"
       environment:
         ZOO_MY_ID: 6
         ZOO_SERVERS: server.3=10.100.46.3:2888:3888;2181 server.5=10.100.46.5:2888:3888;2181 server.6=10.100.46.6:2888:3888;2181
    
    kafka集群:
    10.100.46.7
    version: '2'
    services:
     kafka:
      image: wurstmeister/kafka
      container_name: kafka-7
      network_mode: "host"
      ports:
        - "9092:9092"
      environment:
       KAFKA_BROKER_ID: 7
       KAFKA_ADVERTISED_HOST_NAME: 10.100.46.7
       KAFKA_ZOOKEEPER_CONNECT: 10.100.46.5:2181,10.100.46.6:2181,10.100.46.3:2181
    
    10.100.46.9
    version: '2'
    services:
      kafka:
       image: wurstmeister/kafka
       container_name: kafka-9
       network_mode: "host"
       ports:
         - "9092:9092"
       environment:
        KAFKA_BROKER_ID: 9
        KAFKA_ADVERTISED_HOST_NAME: 10.100.46.9
        KAFKA_ZOOKEEPER_CONNECT: 10.100.46.5:2181,10.100.46.6:2181,10.100.46.3:2181
    
    kafka manager :
    docker run -d -p 9000:9000  --name kafka_manager -eZK_HOSTS=10.100.46.3 kafkamanager/kafka-manager
    

你可能感兴趣的:(kafka,zookeeper,docker,zookeeper,跨机器,kafka)