一、安装准备
zookeeper-3.4.5 安装,在三台服务器上操作
环境准备:3台centos ip分别是192.168.158.11、192.168.158.12、192.168.158.13
设置hosts
echo "192.168.158.11 node1">>/etc/hosts
echo "192.168.158.12 node2">>/etc/hosts
echo "192.168.158.13 node3">>/etc/hosts
安装jdk 相见https://blog.csdn.net/eakom/article/details/78795083
cd /usr/local
tar -xzvf jdk-7u79-linux-x64.tar.gz
echo "export JAVA_HOME=/usr/local/jdk1.7.0_79">>/etc/profile
echo "export CLASSPATH=.:JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar">>/etc/profile
source /etc/profile
echo "export PATH=$JAVA_HOME/bin:$PATH">>/etc/profile
source /etc/profile
二、安装步骤
1.上传文件并解压
cd /usr/local/
tar -xzvf zookeeper-3.4.5.tar.gz
2.配置环境变量
echo "export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.5">>/etc/profile
source /etc/profile
echo "export PATH=$ZOOKEEPER_HOME/bin:$PATH">>/etc/profile
source /etc/profile
3.修改zookeeper配置文件
cd /usr/local/zookeeper-3.4.5/conf
cp zoo_sample.cfg zoo.cfg
vi zoo.cfg
修改dataDir=/usr/local/zookeeper-3.4.5/data
添加
server.0=node1:2888:3888
server.1=node2:2888:3888
server.2=node3:2888:3888
注:2888为服务器的同步端口,3888为服务器重新选举端口
4.设置标记配置
分别在各个服务器在创建不同的标记
node1对应命令 echo 0 > /usr/local/zookeeper-3.4.5/data/myid
node2对应命令 echo 1 > /usr/local/zookeeper-3.4.5/data/myid
node3对应命令 echo 2 > /usr/local/zookeeper-3.4.5/data/myid
5.启动
6.查看状态
zkServer.sh status