jdk-8u221-linux-x64.zip
[root@alice002 ~]# mkdir /usr/java
[root@alice002 ~]# cd /opt/src
[root@alice002 src]# tar -xf jdk-8u221-linux-x64.tar.gz -C /usr/java/
[root@alice002 src]# ln -s /usr/java/jdk1.8.0_221/ /usr/java/jdk
[root@alice002 src]# cat >>/etc/profile <<'EOF'
> #JAVA HOME
> export JAVA_HOME=/usr/java/jdk
> export PATH=$JAVA_HOME/bin:$JAVA_HOME/bin:$PATH
> export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
> EOF
[root@alice002 src]# source /etc/profile
[root@alice002 src]# java -version
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
[root@alice002 src]#
wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz
[root@alice001 src]# tar -zxf zookeeper-3.4.14.tar.gz -C /opt/
[root@alice001 src]# ln -s /opt/zookeeper-3.4.14/ /opt/zookeeper
[root@alice001 src]# ll /opt/zookeeper
lrwxrwxrwx 1 root root 22 Mar 1 21:16 /opt/zookeeper -> /opt/zookeeper-3.4.14/
[root@alice001 src]# cat >/opt/zookeeper/conf/zoo.cfg <<'EOF'
> tickTime=2000
> initLimit=10
> syncLimit=5
> dataDir=/data/zookeeper/data
> dataLogDir=/data/zookeeper/logs
> clientPort=2181
> server.1=zk1.od.com:2888:3888
> server.2=zk2.od.com:2888:3888
> server.3=zk3.od.com:2888:3888
> EOF
[root@alice001 src]# mkdir -p /data/zookeeper/data
[root@alice001 src]# mkdir -p /data/zookeeper/logs
[root@alice001 src]# echo 1 > /data/zookeeper/data/myid 分别为每台机器添加id
[root@alice001 src]# vim /var/named/od.com.zone 记得前滚序列
zk1 A 172.23.187.175
zk2 A 172.23.187.173
zk3 A 172.23.187.174
[root@alice001 src]# systemctl restart named
[root@alice001 src]# dig -t A zk1.od.com @172.23.187.175 +short
172.23.187.175
[root@alice001 src]# dig -t A zk2.od.com @172.23.187.175 +short
172.23.187.173
[root@alice001 src]# dig -t A zk3.od.com @172.23.187.175 +short
172.23.187.174
[root@alice001 src]# /opt/zookeeper/bin/zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@alice001 src]# netstat -lntup |grep 2181
tcp 0 0 0.0.0.0:2181 0.0.0.0:* LISTEN 5191/java
[root@alice001 src]# /opt/zookeeper/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
Mode: follower
[root@alice001 src]#