Zookeeper源码包下载
http://mirror.bit.edu.cn/apache/zookeeper/
1. 集群环境
Master 192.168.2.100
Slave1 192.168.2.101
Slave2 192.168.2.102
2. 下载软件包
#Master
wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.5.3/zookeeper-3.5.3.tar.gz
tar zxvf zookeeper-3.5.3.tar.gz
3. 修改zookeeper配置
#Master
cd zookeeper-3.5.3
#创建日志文件夹及数据文件夹
mkdir data
mkdir log
#修改配置
cd conf
mv zoo_sample.cfg zoo.cfg
vim zoo.cfg
dataDir=/usr/local/zookeeper-3.5.3-beta/data
dataLogDir=/usr/local/zookeeper-3.5.3/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/zookeeper-3.5.3
PATH=$PATH:$ZOOKEEPER_HOME/bin
#刷新环境变量
source ~/.bashrc
5. 拷贝安装包
#Master
scp -r /usr/local/zookeeper-3.5.3 root@slave1:/usr/local/zookeeper-3.5.3
scp -r /usr/local/zookeeper-3.5.3 root@slave2:/usr/local/zookeeper-3.5.3
6. 分别添加ID
ID要与配置文件中server.*中的数字对应
#Master
echo "1" > /usr/local/zookeeper-3.5.3/data/myid
#Slave1
echo "2" > /usr/local/zookeeper-3.5.3/data/myid
#Slave2
echo "3" > /usr/local/zookeeper-3.5.3/data/myid
7. 启动Zookeeper服务
#Master、Slave1、Slave2
Slave1、Slave2也要执行此命令
zkServer.sh start
8. 查看运行状态
zkServer.sh status
#Master
#Slave1
#Slave2
9. 进程状态
jps
#Master #Slave1 #Slave2
10. 关闭集群
#master、Slave1、Slave2
zkServer.sh stop
三台机器都要执行此命令
原创文章,作者:carmelaweatherly,如若转载,请注明出处:https://blog.ytso.com/197018.html