• docker 使用compose安装zookeeper集群


    此基础镜像使用的为zookeeper的官方镜像

    docker pull zookeeper

    新建文件 docker-compose.yml

    version: '2'
    services:
      zookeeper1:
        image: zookeeper
        container_name: zk1.cloud
        ports:
            - "2181:2181"
        environment:
          ZOO_MY_ID: 1
          ZOO_SERVERS: server.1=0.0.0.0:2888:3888 server.2=zk2.cloud:2888:3888 server.3=zk3.cloud:2888:3888
      zookeeper2:
        image: zookeeper
        container_name: zk2.cloud
        ports:
            - "2182:2181"
        environment:
          ZOO_MY_ID: 2
          ZOO_SERVERS: server.1=zk1.cloud:2888:3888 server.2=0.0.0.0:2888:3888 server.3=zk3.cloud:2888:3888
      zookeeper3:
        image: zookeeper
        container_name: zk3.cloud
        ports:
            - "2183:2181"
        environment:
          ZOO_MY_ID: 3
          ZOO_SERVERS: server.1=zk1.cloud:2888:3888 server.2=zk2.cloud:2888:3888 server.3=0.0.0.0:2888:3888

    启动集群

    docker-compose up

    后台启动

    docker-compose up -d

    查看启动状态

    docker-compose ps

     查看主从关系: 

    echo stat | nc www.wenbronk.com 2181

    可看另外两个端口  2182, 2183

    还可以在启动时直接指定

    docker run -d 
     -p 2181:2181 
     --name zk1 
     --link zk2:zknode2 
     --link zk3:zknode3 
     --net foo 
     -e SERVER_ID=1 
     -e ADDITIONAL_ZOOKEEPER_1=server.1=0.0.0.0:2888:3888 
     -e ADDITIONAL_ZOOKEEPER_2=server.2=zknode2:2888:3888 
     -e ADDITIONAL_ZOOKEEPER_3=server.3=zknode3:2888:3888 
     zookeeper
    docker run -d 
     -p 2182:2181 
     --name zk2 
     --link zk1:zknode1 
     --link zk3:zknode3 
     --net foo 
     -e SERVER_ID=1 
     -e ADDITIONAL_ZOOKEEPER_1=server.1=zknode1:2888:3888 
     -e ADDITIONAL_ZOOKEEPER_2=server.2=0.0.0.0:2888:3888 
     -e ADDITIONAL_ZOOKEEPER_3=server.3=zknode3:2888:3888 
     zookeeper
    docker run -d 
     -p 2183:2181 
     --name zk3 
     --link zk2:zknode2 
     --link zk1:zknode1 
     --net foo 
     -e SERVER_ID=1 
     -e ADDITIONAL_ZOOKEEPER_1=server.1=zknode1:2888:3888 
     -e ADDITIONAL_ZOOKEEPER_2=server.2=zknode2:2888:3888 
     -e ADDITIONAL_ZOOKEEPER_3=server.3=0.0.0.0:2888:3888 
     zookeeper
  • 相关阅读:
    MySQL Execution Plan--合理利用隐式的业务逻辑
    MySQL Table--MySQL外键
    MySQL倒序索引测试2
    MySQL倒序索引测试1
    CCNA-3.硬件介质
    CCNA-2.OSI 7层网络模型
    CCNA-1.认识网络
    windows本地安装Oracle数据库
    扫码登录实现原理
    phpunit 单元测试
  • 原文地址:https://www.cnblogs.com/wenbronk/p/6438492.html
Copyright © 2020-2023  润新知