docker run -d --restart=always --net=host -v /data/zookeeper/zoo1/data:/data -v /data/zookeeper/datalog:/datalog -e ZOO_MY_ID=1 -e ZOO_SERVERS="server.1=10.128.0.111:2888:3888 server.2=10.128.0.112:2888:3888 server.3=10.128.0.113:2888:3888" --name=zookeeper-1 zookeeper:3.4.14
docker run -d --restart=always --net=host -v /data/zookeeper/zoo2/data:/data -v /data/zookeeper/datalog:/datalog -e ZOO_MY_ID=2 -e ZOO_SERVERS="server.1=10.128.0.111:2888:3888 server.2=10.128.0.112:2888:3888 server.3=10.128.0.113:2888:3888" --name=zookeeper-2 zookeeper:3.4.14
docker run -d --restart=always --net=host -v /data/zookeeper/zoo3/data:/data -v /data/zookeeper/datalog:/datalog -e ZOO_MY_ID=3 -e ZOO_SERVERS="server.1=10.128.0.111:2888:3888 server.2=10.128.0.112:2888:3888 server.3=10.128.0.113:2888:3888" --name=zookeeper-3 zookeeper:3.4.14
三台虚拟机,安装docker后分别执行以上命令
注意ZOO_MY_ID代表每台机器的标识
如果日志有报错,确保同时启动zookeeper