一、 安装Docker
(略)
二、 安装Docker Compose
(略)
三、 编写docker-compose.yml文件
3.1 新建配置文件
touch cluster.yml
vim cluster.yml
cluster.yml
配置如下
version: '3.7'
services:
zoo1:
image: zookeeper:3.5.5
restart: always
hostname: zoo1
container_name: zookeeper_1
volumes:
- /usr/local/use_data/zookeeper/cluster/zoo_1/data:/data
- /usr/local/use_data/zookeeper/cluster/zoo_1/log:/datalog
ports:
- 2181: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:3.5.5
restart: always
hostname: zoo2
container_name: zookeeper_2
volumes:
- /usr/local/use_data/zookeeper/cluster/zoo_2/data:/data
- /usr/local/use_data/zookeeper/cluster/zoo_2/log:/datalog
ports:
- 2182: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:3.5.5
restart: always
hostname: zoo3
container_name: zookeeper_3
volumes:
- /usr/local/use_data/zookeeper/cluster/zoo_3/data:/data
- /usr/local/use_data/zookeeper/cluster/zoo_3/log:/datalog
ports:
- 2183: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
3.2 启动容器
$ docker-compose -f ./cluster.yml up -d
3.3 查看容器状态
$ docker-compose -f ./cluster.yml ps
3.4 查看容器日志
$ docker-compose -f ./cluster.yml logs zoo1
四、 使用图形化界面
4.1 下载ZooInspector工具
4.2 运行jar
- 打开
.\ZooInspector\build
- 打开
cmd
- 执行
java -jar zookeeper-dev-ZooInspector.jar
4.3 连接到zookeeper
4.4 新增节点
来源:oschina
链接:https://my.oschina.net/u/4178242/blog/3101619