docker学习——zookeeper集群安装
本文主要介绍zookeeper在docker的集群安装。
1、首先下载zookeeper
docker pull zookeeper
2、安装docker-compose 插件
3、编写docker-compose.yml 文件,内容如下:
version: '2'
services:
zoo1:
image: zookeeper
restart: always
ports:
- 62181:2181
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
zoo2:
image: zookeeper
restart: always
ports:
- 62182:2181
environment:
ZOO_MY_ID: 2
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
zoo3:
image: zookeeper
restart: always
ports:
- 62183:2181
environment:
ZOO_MY_ID: 3
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
4、使用命令,启动zookeeper集群
docker-compse up -d
5、查看docker中zookeeper的状态
6、这样就完成了docker下的zookeeper的安装。