compose.yml 文件
services:
zoo1:
image: zookeeper:3.8.3
restart: always
hostname: zoo1
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
volumes:
- ./zk1-conf:/conf
- ./zk1-data:/data
zoo2:
image: zookeeper:3.8.3
restart: always
hostname: zoo2
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
volumes:
- ./zk2-conf:/conf
- ./zk2-data:/data
zoo3:
image: zookeeper:3.8.3
restart: always
hostname: zoo3
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
volumes:
- ./zk3-conf:/conf
- ./zk3-data:/data
- 其中volumes数据卷的宿主机文件夹
./zk*-conf
,./zk*-data
,要改权限可读写执行chmod 777 ./zk*