docker安装zookeeper集群

IT
IT
IT
335
文章
1
评论
2020年7月24日20:53:49 评论 1,204 1795字阅读5分59秒

下载镜像

[root@master scripts]# docker pull zookeeper
Using default tag: latest
latest: Pulling from library/zookeeper
6ec8c9369e08: Pull complete 
3aa4e9b77806: Pull complete 
6d8b5d3bc409: Pull complete 
2d63bc6ae267: Pull complete 
1ee2c0f6da3c: Pull complete 
4d8007b1503e: Pull complete 
7b4a7b568288: Pull complete 
2db26ac8ef3a: Pull complete 
Digest: sha256:b6ac831c5610bed6ba281e3d7a2c3162af150d27ac9b3df82e4b0bd4e4153fa0
Status: Downloaded newer image for zookeeper:latest
docker.io/library/zookeeper:latest

单节点启动zookeeper镜像

[root@master ~]# docker run --name my_zookeeper -d -p 2181:2181 zookeeper:latest

使用 docker-compose启动集群

[root@master ~]# vim docker-compose.yml
version: '3.1'

services:
  zoo1:
    image: zookeeper
    restart: always
    hostname: zoo1
    ports:
      - 5181:2181
    environment:
      ZOO_MY_ID: 1
      ZOO_SERVERS: server.1=0.0.0.0:2888:3888;2181 server.2=zoo2:2888:3888;2181 server.3=zoo3:2888:3888;2181

  zoo2:
    image: zookeeper
    restart: always
    hostname: zoo2
    ports:
      - 5182:2181
    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

  zoo3:
    image: zookeeper
    restart: always
    hostname: zoo3
    ports:
      - 5183:2181
    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

 

启动zookeeper集群

[root@master ~]# docker-compose up -d
Creating network "root_default" with the default driver
Creating root_zoo3_1 ... done
Creating root_zoo1_1 ... done
Creating root_zoo2_1 ... done
[root@master ~]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                  NAMES
a7110bca4b53        zookeeper           "/docker-entrypoint.…"   6 seconds ago       Up 4 seconds        2888/tcp, 3888/tcp, 8080/tcp, 0.0.0.0:5181->2181/tcp   root_zoo1_1
c895691980df        zookeeper           "/docker-entrypoint.…"   6 seconds ago       Up 4 seconds        2888/tcp, 3888/tcp, 8080/tcp, 0.0.0.0:5182->2181/tcp   root_zoo2_1
3a72560d3325        zookeeper           "/docker-entrypoint.…"   6 seconds ago       Up 4 seconds        2888/tcp, 3888/tcp, 8080/tcp, 0.0.0.0:5183->2181/tcp   root_zoo3_1

 

继续阅读
  • 我的QQ
  • QQ扫一扫
  • weinxin
  • 我的头条
  • 头条扫一扫
  • weinxin
IT
  • 本文由 发表于 2020年7月24日20:53:49
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
zookeeper集群 zookeeper

zookeeper集群

简介 ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性服务的软件,提...
zookeeper可视化界面 zookeeper

zookeeper可视化界面

安装maven 生成zkui的jar包 修改成自己所需信息 # git clone https://gitee.com/ilanni/zkui.git Cloning into 'zkui'... r...
Docker部署Apollo Apollo

Docker部署Apollo

安装docker $ cd /opt/ $ sudo git clone --depth=1 https://github.com/cncentoscn/setuptools.git $ cd set...