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
8. 查看运行状态
zkServer.sh status
#Master
#Slave1
#Slave2
9. 进程状态
jps
#Master
#Slave1
#Slave2
10. 关闭集群
#master、Slave1、Slave2
zkServer.sh stop