【6.9.5】服务器安装 Docker Swarm中搭建 Zookeeper 集群

https://hub.docker.com/_/zookeeper

mkdir -p /home/zk/zookeeper1/data
mkdir -p /home/zk/zookeeper1/conf
mkdir -p /home/zk/zookeeper1/logs
#docker-compose.yaml
version: '3'

services:
  zoo1:
    image: zookeeper:3.6.1
    restart: always
    hostname: zoo1
    ports:
      - 2181:2181
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /home/zk/zookeeper1/data:/data
      - /home/zk/zookeeper1/datalog:/datalog
    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
    networks:
      zookeeper_default:
    deploy:
      placement:
        constraints:
          - node.hostname == worker1      

  zoo2:
    image: zookeeper:3.6.1
    restart: always
    hostname: zoo2
    ports:
      - 2182:2181
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /home/zk/zookeeper2/data:/data
      - /home/zk/zookeeper2/datalog:/datalog 
    environment:
      ZOO_MY_ID: 2
      ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=zoo3:2888:3888;2181
    networks:
      zookeeper_default:
    deploy:
      placement:
        constraints:
          - node.hostname == worker1
  zoo3:
    image: zookeeper:3.6.1
    restart: always
    hostname: zoo3
    ports:
      - 2183:2181
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /home/zk/zookeeper3/data:/data
      - /home/zk/zookeeper3/datalog:/datalog
    environment:
      ZOO_MY_ID: 3
      ZOO_SERVERS: server.1=zoo1:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=zoo3:2888:3888;2181
    networks:
      zookeeper_default:
    deploy:
      placement:
        constraints:
          - node.hostname == worker1      
  zkui:
    image: registry.cn-hangzhou.aliyuncs.com/wkaca7114/zkui
    container_name: zkui
    ports:
      - 9010:9090
    depends_on:
      - zoo1
    links:
      - zoo1
    environment:
      ZK_SERVER: zoo1:2181   

访问http://192.168.0.103:9010/login 这里用你自己的ip

image.png

zkui 默认账户密码 admin/manager

image.png

点波关注 系统搭建(docker)

你可能感兴趣的:(【6.9.5】服务器安装 Docker Swarm中搭建 Zookeeper 集群)