准备3台机器
安装
docker run -d --name zookeeper --net host --restart always -e ZOO_MY_ID=1 \
-e ZOO_SERVERS="server.1=192.168.3.17:2888:3888;2181 server.2=192.168.3.19:2888:3888;2181 server.3=192.168.3.20:2888:3888;2181" \
-v /root/zookeeper/data:/data -v /root/zookeeper/datalog:/datalog zookeeper:3.7
docker run -d --name zookeeper --net host --restart always -e ZOO_MY_ID=2 \
-e ZOO_SERVERS="server.1=192.168.3.17:2888:3888;2181 server.2=192.168.3.19:2888:3888;2181 server.3=192.168.3.20:2888:3888;2181" \
-v /root/zookeeper/data:/data -v /root/zookeeper/datalog:/datalog zookeeper:3.7
docker run -d --name zookeeper --net host --restart always -e ZOO_MY_ID=3 \
-e ZOO_SERVERS="server.1=192.168.3.17:2888:3888;2181 server.2=192.168.3.19:2888:3888;2181 server.3=192.168.3.20:2888:3888;2181" \
-v /root/zookeeper/data:/data -v /root/zookeeper/datalog:/datalog zookeeper:3.7
docker exec -it zookeeper bash
zkCli.sh -server 192.168.3.17
create /mynode hello
get /mynode