以3.5.7为例
配置文件:
dataDir=/data
dataLogDir=/datalog
tickTime=2000
initLimit=5
syncLimit=2
autopurge.snapRetainCount=3
autopurge.purgeInterval=0
maxClientCnxns=60
admin.enableServer=true
clientPort=2181
server.1=10.163.204.193:2888:3888
server.2=10.163.204.194:2888:3888
server.3=0.0.0.0:2888:3888
docker-compose.yml文件:
version: '3.1'
services:
zookeeper:
image: zookeeper:3.5.7
restart: always
container_name: zk-3
volumes:
- /data/zk/data:/data
- /data/zk/datalog:/datalog
- /home/zk/zookeeper-3.5.7/conf/zoo.cfg:/conf/zoo.cfg
environment:
ZOO_MY_ID: 3
ports:
- 2181:2181
- 2888:2888
- 3888:3888
- 8080:8080
查看集群状态,主从信息
docker exec -it zk-3 bash ./bin/zkServer.sh status