• 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
  • 相关阅读:
    lnmp配置支持thinkphp和nginx路由url重写
    服务器空间不足导致mysql服务器无法运行
    linux中安装node
    laravel自定义返回错误方法
    git日常使用
    Hexo博客部署到个人服务器
    Github博客地址
    三种常见字符编码简介:ASCII、Unicode和UTF-8
    自动文档摘要评价方法:Edmundson,ROUGE
    Learning LexRank——Graph-based Centrality as Salience in Text Summarization(一)
  • 原文地址:https://www.cnblogs.com/wenbronk/p/6438492.html
Copyright © 2020-2023  润新知