码迷,mamicode.com
首页 > 其他好文 > 详细

docker 使用compose安装zookeeper集群

时间:2017-02-24 15:50:48      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:启动   http   ges   code   dock   docker   集群   env   查看   

新建文件 docker-compose.yml

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

      - SERVER_ID=3
      - ADDITIONAL_ZOOKEEPER_1=server.1=zk1.cloud:2888:3888
      - ADDITIONAL_ZOOKEEPER_2=server.2=zk2.cloud:2888:3888
      - ADDITIONAL_ZOOKEEPER_3=server.3=0.0.0.0:2888:3888

 

启动集群

docker-compose up

后台启动

docker-compose -d up

查看启动状态

docker-compose ps

技术分享

 

 

 

还可以在启动时直接指定

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

 

docker 使用compose安装zookeeper集群

标签:启动   http   ges   code   dock   docker   集群   env   查看   

原文地址:http://www.cnblogs.com/wenbronk/p/6438492.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!