🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
### 1、介绍 本次交付的服务架构图:因为zookeeper属于有状态服务,不建议将有状态服务,交付到k8s,如mysql,zk等 首先部署zk集群:zk是java服务,需要依赖jdk,jdk请自行下载: 集群部署集群为HDSS7-21,HDSS7-22,HDSS7-23 上传安装包到/usr/local/java中解压 ``` mkdir /usr/local/java/ mv jdk1.8.0\_171/ /usr/local/java/ ln -s /usr/local/java/jdk1.8.0\_171/ /usr/local/java/jdk 在文件/etc/profile末尾添加以下内容: export JAVA\_HOME=/usr/local/java/jdk export JRE\_HOME=/usr/local/java/jdk/jre export CLASSPATH=.:$JAVA\_HOME/lib/dt.jar:$JAVA\_HOME/lib/tools.jar:$JRE\_HOME/lib:$CLASSPATH export PATH=$JAVA\_HOME/bin:$PATH source /etc/profile java -version ``` ### 2、下载zookeeper部署 下载地址:https://archive.apache.org/dist/zookeeper/ ``` tar zxvf /usr/local/src/zookeeper-3.4.14.tar.gz -C /opt/ ln -s /opt/zookeeper-3.4.14/ /opt/zookeeper mkdir -pv /data/zookeeper/data /data/zookeeper/logs ``` 配置文件修改: mv /opt/zookeeper/conf/zoo_sample.cfg /opt/zookeeper/conf/zoo.cfg cat /opt/zookeeper/conf/zoo.cfg ``` 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 ``` ### 3、修改dns: vim /var/named/od.com.zone zk1 A 10.4.7.21 zk2 A 10.4.7.22 zk3 A 10.4.7.23 ####  修改zk集群 ``` 7-121 echo 1 > /data/zookeeper/data/myid 7-22 echo 2 > /data/zookeeper/data/myid 7-23 echo 3 > /data/zookeeper/data/myid ``` ### 4、启动服务 /opt/zookeeper/bin/zkServer.sh start [root@hdss7-21 opt]# netstat -lntp| grep 2181 tcp6 0 0 :::2181 :::* LISTEN 108043/java ### 5、查看主节点位置 [root@hdss7-21 zookeeper]# /opt/zookeeper/bin/zkServer.sh status ZooKeeper JMX enabled by default Using config: /opt/zookeeper/bin/../conf/zoo.cfg Mode: leader 主节点 Mode: follower 从节点 到此,zookeeper集群就搭建好了