zookeeper集群
安装jdk8
cd /opt/tools
tar -xf jdk-8u112-linux-x64.tar.gz
mv jdk1.8.0_112 /opt/
vim /etc/profile.d/env.sh
######
export JAVA_HOME=/opt/jdk1.8.0_112
export JAVA_BIN=/opt/jdk1.8.0_112/bin
export JRE_HOME=/opt/jdk1.8.0_112/jre
export PATH=$PATH:/opt/jdk1.8.0_112/bin:/opt/jdk1.8.0_112/jre/bin
export CLASSPATH=/opt/jdk1.8.0_112/jre/lib:/opt/jdk1.8.0_112/lib:/opt/jdk1.8.0_112/jre/lib/charsets.jar
######
source /etc/profile
[root@docker1 tools]# java -version
java version "1.8.0_112"
Java(TM) SE Runtime Environment (build 1.8.0_112-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)
节点1
mkdir /opt/zkcluster cd /opt/tools tar -xf zookeeper-3.4.10.tar.gz mv zookeeper-3.4.10 /opt/zkcluster/3001 cd /opt/zkcluster/3001 mkdir data logs cd conf vim zoo.cfg ##### tickTime=2000 initLimit=10 syncLimit=5 dataDir=/opt/zkcluster/3001/data dataLogDir=/opt/zkcluster/3001/logs clientPort=3001 server.1=192.168.159.30:2887:3887 server.2=192.168.159.30:2888:3888 server.3=192.168.159.30:2889:3889 #主要修改ip,端口 ##### echo 1 > /opt/zkcluster/3001/data/myid 启动 /opt/zkcluster/3001/bin/zkServer.sh start
节点2
cd /opt/cluster cp -av 3001 3002 sed -i 's/3001/3002/g' /opt/zkcluster/3002/conf/zoo.cfg echo 2 > /opt/zkcluster/3002/data/myid
启动
/opt/zkcluster/3002/bin/zkServer.sh start
节点3
cd /opt/cluster cp -av 3001 3003 sed -i 's/3001/3003/g' /opt/zkcluster/3003/conf/zoo.cfg echo 3 > /opt/zkcluster/3003/data/myid 启动 /opt/zkcluster/3002/bin/zkServer.sh start
验证集群
[root@docker1 conf]# /opt/zkcluster/3001/bin/zkServer.sh status ZooKeeper JMX enabled by default Using config: /opt/zkcluster/3001/bin/../conf/zoo.cfg Mode: leader [root@docker1 conf]# /opt/zkcluster/3002/bin/zkServer.sh status ZooKeeper JMX enabled by default Using config: /opt/zkcluster/3002/bin/../conf/zoo.cfg Mode: follower [root@docker1 conf]# /opt/zkcluster/3003/bin/zkServer.sh status ZooKeeper JMX enabled by default Using config: /opt/zkcluster/3003/bin/../conf/zoo.cfg Mode: follower