zookeeper集群部署

下载zookeeper  docker镜像

docker pull zookeeper

编写docker-compose.yml配置文件

version: '3.4'
x-logging:
  &default-logging
  options:
    max-size: '12m'
    max-file: '5'
  driver: json-file
services:
  zoo1:
    image: zookeeper
    logging: *default-logging
    restart: always
    hostname: zoo1
    networks:
       doufy:
         ipv4_address: 172.19.0.11
    environment:
      ZOO_MY_ID: 1
      ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=zoo3:2888:3888;2181
    volumes:
      -  /etc/localtime:/etc/localtime:ro
      - /data/zook01/data:/data
      - /data/zook01/datalog:/datalog
  zoo2:
    image: zookeeper
    logging: *default-logging
    restart: always
    hostname: zoo2
    networks:
       doufy:
         ipv4_address: 172.19.0.12

    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:
      -  /etc/localtime:/etc/localtime:ro
      - /data/zook02/data:/data
      - /data/zook02/datalog:/datalog

  zoo3:
    image: zookeeper
    logging: *default-logging
    restart: always
    hostname: zoo3
    networks:
       doufy:
         ipv4_address: 172.19.0.13
    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:
      -  /etc/localtime:/etc/localtime:ro
      - /data/zook03/data:/data
      - /data/zook03/datalog:/datalog
networks:
    doufy:
      external: true

启动

 docker-compose up -d

查看状态,进入容器内执行

zkServer.sh  staus
上一篇:ZooKeeper简介


下一篇:我的Spring Boot学习记录(二):Tomcat Server以及Spring MVC的上下文问题