1.准备3台机器,IP为
192.168.1.181 192.168.1.182 192.168.1.159
2.创建目录
mkdir conf data datalog
3.创建配置文件
vi conf/zoo.cfg
文件内容
tickTime=2000 initLimit=5 syncLimit=2 #maxClientCnxns=60 #autopurge.snapRetainCount=3 #autopurge.purgeInterval=1 dataDir=/data dataLogDir=/datalog clientPort=2181 server.1=192.168.1.181:2888:3888 server.2=192.168.1.182:2888:3888 server.3=192.168.1.159:2888:3888
4.创建myid,注意每台机器的文件内容不一样,我的分别为1、2、3
vi data/myid
5.分别启动zookeeper
docker run -d -p 2181:2181 -p 2888:2888 -p 3888:3888 --restart=always \ -v /data:/opt/zookeeper/data \ -v /datalog:/opt/zookeeper/logs \ -v /conf:/opt/zookeeper/conf \ --name=zk1 \ zookeeper:3.5.7
docker run -d -p 2181:2181 -p 2888:2888 -p 3888:3888 --restart=always \ -v /data:/opt/zookeeper/data \ -v /datalog:/opt/zookeeper/logs \ -v /conf:/opt/zookeeper/conf \ --name=zk2 \ zookeeper:3.5.7
docker run -d -p 2181:2181 -p 2888:2888 -p 3888:3888 --restart=always \ -v /data:/opt/zookeeper/data \ -v /datalog:/opt/zookeeper/logs \ -v /conf:/opt/zookeeper/conf \ --name=zk3 \ zookeeper:3.5.7
来源:https://www.cnblogs.com/418836844qqcom/p/12462317.html