docker-compose部署zk和kafka

version: '3.4'

services:
  zk1:
    image: zookeeper
    restart: always
    hostname: zk1
    container_name: zk1
    ports:
    - 12181:2181
    volumes:
    - "/home/smb/data/zkcluster/zk1:/data"
    - "/home/smb/logs/zkcluster/zk1:/datalog"
    environment:
      ZOO_MY_ID: 1
      ZOO_SERVERS: server.1=0.0.0.0:2888:3888;2181 server.2=zk2:2888:3888;2181 server.3=zk3:2888:3888;2181
    networks:
      - smb

  zk2:
    image: zookeeper
    restart: always
    hostname: zk2
    container_name: zk2
    ports:
    - 12182:2181
    volumes:
    - "/home/smb/data/zkcluster/zk2:/data"
    - "/home/smb/logs/zkcluster/zk2:/datalog"
    environment:
      ZOO_MY_ID: 2
      ZOO_SERVERS: server.1=0.0.0.0:2888:3888;2181 server.2=zk2:2888:3888;2181 server.3=zk3:2888:3888;2181
    networks:
      - smb

  zk3:
    image: zookeeper
    restart: always
    hostname: zk3
    container_name: zk3
    ports:
    - 12183:2181
    volumes:
    - "/home/smb/data/zkcluster/zk3:/data"
    - "/home/smb/logs/zkcluster/zk3:/datalog"
    environment:
      ZOO_MY_ID: 3
      ZOO_SERVERS: server.1=0.0.0.0:2888:3888;2181 server.2=zk2:2888:3888;2181 server.3=zk3:2888:3888;2181
    networks:
      - smb

  kafka1:
    image: wurstmeister/kafka
    restart: always
    hostname: kafka1
    container_name: kafka1
    ports:
    - 19091:9091
    environment:
      KAFKA_ADVERTISED_HOST_NAME: kafka1
      KAFKA_ADVERTISED_PORT: 9091
      KAFKA_ZOOKEEPER_CONNECT: zk1:2181,zk2:2181,zk3:2181
    volumes:
    - /home/smb/logs/kfkcluster/kafka1:/kafka
    networks:
      - smb

  kafka2:
    image: wurstmeister/kafka
    restart: always
    hostname: kafka2
    container_name: kafka2
    ports:
    - 19092:9092
    environment:
      KAFKA_ADVERTISED_HOST_NAME: kafka2
      KAFKA_ADVERTISED_PORT: 9092
      KAFKA_ZOOKEEPER_CONNECT: zk1:2181,zk2:2181,zk3:2181
    volumes:
    - /home/smb/logs/kfkcluster/kafka2:/kafka
    networks:
      - smb

  kafka3:
    image: wurstmeister/kafka
    restart: always
    hostname: kafka3
    container_name: kafka3
    ports:
    - 19093:9093
    environment:
      KAFKA_ADVERTISED_HOST_NAME: kafka3
      KAFKA_ADVERTISED_PORT: 9093
      KAFKA_ZOOKEEPER_CONNECT: zk1:2181,zk2:2181,zk3:2181
    volumes:
    - /home/smb/logs/kfkcluster/kafka3:/kafka
    networks:
      - smb

networks:
  smb:

  

上一篇:Security Guards (Gym - 101954B)( bfs + 打表 )


下一篇:docker-compose部署redis-cluster