阿里云ZooKeeper搭建伪集群\
// 下载zookeeper-3.4.14.tar.gz
wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz
// 创建目录zkcluster
mkdir zkcluster
// 解压zookeeper-3.4.14.tar.gz到目录zkcluster下
tar -zxvf zookeeper-3.4.14.tar.gz -C zkcluster
// 修改名称
cd zkcluster
mv zookeeper-3.4.14 zookeeper01
// 复制修改并名称
cp -r zookeeper01/ zookeeper02
cp -r zookeeper01/ zookeeper03
//分别在zookeeper01,zookeeper02,zookeeper03目录下创建data目录,在data下创建logs目录
cd zookeeper01
mkdir data
cd data
mkdir logs
cd ../../zookeeper02
mkdir data
cd data
mkdir logs
cd ../../zookeeper03
mkdir data
cd data
mkdir logs
// 修改配置文件
cd ../../zookeeper01/conf
mv zoo_sample.cfg zoo.cfg
vim zoo.cfg
clientPort=2181
dataDir=/root/zkcluster/zookeeper01/data
dataLogDir=/root/zkcluster/zookeeper01/data/logs
cd ../../zookeeper01/conf
mv zoo_sample.cfg zoo.cfg
vim zoo.cfg
clientPort=2182
dataDir=/root/zkcluster/zookeeper02/data
dataLogDir=/root/zkcluster/zookeeper02/data/logs
cd ../../zookeeper02/conf
mv zoo_sample.cfg zoo.cfg
vim zoo.cfg
clientPort=2183
dataDir=/root/zkcluster/zookeeper03/data
dataLogDir=/root/zkcluster/zookeeper03/data/logs
// 配置伪集群,在每个zk的data目录下创建myid文件,内容分别为1,2,3.标识每个服务器ID
touch myid
// 在每个zk配置文件配置集群服务列表
server.1=127.0.0.1:2881:3881
server.2=127.0.0.1:2882:3882
server.3=127.0.0.1:2883:3883
#server.服务器ID=服务器IP地址:服务器之间通信端口:服务器之间投票选举端口
// 依次启动zk
./zkServer.sh start
// 查看状态
./zkServer.sh status