源码包下载:
http://archive.apache.org/dist/zookeeper/zookeeper-3.4.10
集群环境:
master 192.168.1.99 slave1 192.168.1.100 slave2 192.168.1.101
下载安装包:
# Mater wget http://archive.apache.org/dist/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz -C /usr/local/src tar -zxvf zookeeper-3.4.10.tar.gz
mv zookeeper-3.4.10 /usr/local/zookeeper
修改配置文件:
cd /usr/local/zookeeper/conf
mv zoo_sample.cfg zoo.cfg
vim zoo.cfg
dataDir=/usr/local/zookeeper/data
dataLogDir=/usr/local/zookeeper/log
server.1=master:2888:3888
server.2=slave1:2888:3888
server.3=slave2:2888:3888
#创建临时目录和文件目录
mkdir /usr/local/zookeeper/data
mkdir /usr/local/zookeeper/log
配置环境变量:
#Master slave1 slave2
vim ~/.bashrc ZOOKEEPER_HOME=/usr/local/zookeeper PATH=$PATH:$ZOOKEEPER_HOME/bin#刷新环境变量 source ~/.bashrc
拷贝安装包:
scp -r /usr/local/zookeeper/ slave1:/usr/local/zookeeper/
scp -r /usr/local/zookeeper/ slave2:/usr/local/zookeeper/
分别添加不同的ID:
#Master echo "1" > /usr/local/zookeeper/data/myid #Slave1 echo "2" > /usr/local/zookeeper/data/myid #Slave2 echo "3" > /usr/local/zookeeper/data/myid
启动Zookeeper服务:
说明:需分别在对应的机器上面启动
zkServer.sh start (zkServer.sh status 查看zookeeper状态)
集群状态:
关闭zookeeper服务: