# 下载压缩包
wget https://archive.apache.org/dist/zookeeper/zookeeper-3.5.5/apache-zookeeper-3.5.5-bin.tar.gz
# 解压到指定目录
tar -xzvf apache-zookeeper-3.5.5-bin.tar.gz -C $install_dir
# 复制配置文件
cp $install_dir/conf/zoo_sample.cfg zk1.cfg cp $install_dir/conf/zoo_sample.cfg zk2.cfg cp $install_dir/conf/zoo_sample.cfg zk3.cfg
# 修改配置文件
## zk1.cfg
tickTime=2000 initLimit=10 syncLimit=5 dataDir=....../data/2181 dataLogDir=....../log/2181 clientPort=2181 #maxClientCnxns=60 #autopurge.purgeInterval=1 server.1=127.0.0.1:2181:3881 server.2=127.0.0.1:2182:3882 server.3=127.0.0.1:2183:3883
## zk2.cfg
tickTime=2000 initLimit=10 syncLimit=5 dataDir=....../data/2182 dataLogDir=....../log/2182 clientPort=2182 #maxClientCnxns=60 #autopurge.purgeInterval=1 server.1=127.0.0.1:2181:3881 server.2=127.0.0.1:2182:3882 server.3=127.0.0.1:2183:3883
## zk3.cfg
tickTime=2000 initLimit=10 syncLimit=5 dataDir=....../data/2183 dataLogDir=....../log/2183 clientPort=2183 #maxClientCnxns=60 #autopurge.purgeInterval=1 server.1=127.0.0.1:2181:3881 server.2=127.0.0.1:2182:3882 server.3=127.0.0.1:2183:3883
# 创建 myid文件
echo 1 > ....../data/2181/myid echo 2 > ....../data/2182/myid echo 3 > ....../data/2183/myid
# 启动伪集群
$install_dir/bin/zkServer.sh start zk1.cfg $install_dir/bin/zkServer.sh start zk2.cfg $install_dir/bin/zkServer.sh start zk3.cfg
# ref
* ref1 > https://my.oschina.net/shxjinchao/blog/2877347
* ref2 > https://blog.csdn.net/vbirdbest/article/details/82688462
原文:https://www.cnblogs.com/lwmp/p/11525153.html