0. zookeeper源码包下载
http://mirror.bit.edu.cn/apache/zookeeper/
1. 集群环境
Master 172.16.11.97
Slave1 172.16.11.98
Slave2 172.16.11.99
2. 下载软件包
#Master
wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
tar zxvf zookeeper-3.4.10.tar.gz
3. 修改
zookeeper
配置
#Master
cd zookeeper-3.4.10
#创建日志文件夹及数据文件夹
mkdir data
mkdir log
#修改配置
cd conf
mv zoo_sample.cfg zoo.cfg
vim zoo.cfg
dataDir=/usr/local/src/zookeeper-3.4.10/data
dataLogDir=/usr/local/src/zookeeper-3.4.10/log
server.1=master:2888:3888
server.2=slave1:2888:3888
server.3=slave2:2888:3888
4.
配置环境变量
#Master、Slave1、Slave2
vim ~/.bashrc
ZOOKEEPER_HOME=/usr/local/src/zookeeper-3.4.10
PATH=$PATH:$ZOOKEEPER_HOME/bin
#刷新环境变量
source ~/.bashrc
5. 拷贝安装包
#
Master
scp -r
/usr/local/src/
zookeeper-3.4.10
root@slave1:
/usr/local/src/
zookeeper-3.4.10
scp -r
/usr/local/src/
zookeeper-3.4.10
root@slave2:
/usr/local/src/
zookeeper-3.4.10
6. 分别添加ID
#Master
echo "1" > /usr/local/src/zookeeper-3.4.10/data/myid
#Slave1
echo "2" > /usr/local/src/zookeeper-3.4.10/data/myid
#Slave2
echo "3" > /usr/local/src/zookeeper-3.4.10/data/myid
7. 启动Zookeeper服务
#Master、Slave1、Slave2
zkServer.sh start
![](https://i-blog.csdnimg.cn/blog_migrate/82b273e565902d7327bae109d45a1f66.png)
8. 查看运行状态
zkServer.sh status
#Master
![](https://i-blog.csdnimg.cn/blog_migrate/14793c82331550222d16f6748fb030d1.png)
#Slave1
![](https://i-blog.csdnimg.cn/blog_migrate/750d1e05edb26721d85080638b48985b.png)
#Slave2
![](https://i-blog.csdnimg.cn/blog_migrate/6e051211ccaaa6d9dcaf117ead7754b6.png)
9. 进程状态
jps
#Master
![](https://i-blog.csdnimg.cn/blog_migrate/8277e0eadd1d14ae0148e1417daf94b7.png)
#Slave1
![](https://i-blog.csdnimg.cn/blog_migrate/dfce3fa667c99d8fb6f8ed3dd1a71d3b.png)
#Slave2
![](https://i-blog.csdnimg.cn/blog_migrate/7ba0368e61bd35e1f59f2114be991e78.png)
10.
关闭集群
#master、Slave1、Slave2
zkServer.sh stop
![](https://i-blog.csdnimg.cn/blog_migrate/504ae25859e6dad0361b94994dc5bd75.png)