源码包下载:
http://archive.apache.org/dist/zookeeper/zookeeper-3.4.10
集群环境:
master 192.168.1.99slave1 192.168.1.100slave2 192.168.1.101
下载安装包:
# Materwget http://archive.apache.org/dist/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz -C /usr/local/srctar -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/datamkdir /usr/local/zookeeper/log
配置环境变量:
#Master slave1 slave2
vim ~/.bashrcZOOKEEPER_HOME=/usr/local/zookeeperPATH=$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:
#Masterecho "1" > /usr/local/zookeeper/data/myid #Slave1echo "2" > /usr/local/zookeeper/data/myid #Slave2echo "3" > /usr/local/zookeeper/data/myid
启动Zookeeper服务:
说明:需分别在对应的机器上面启动
zkServer.sh start (zkServer.sh status 查看zookeeper状态)
集群状态:
关闭zookeeper服务: