zookeeper(zk集群)
zookeeper时Dubbo微服务集群的注册中心
它的高可用机制和K8S的etcd集群一致
Java编写
主机名 角色 ip
rstx4-201.rongbiz.cn k8s代理节点1,zk1 192.168.1.201
rstx4-202.rongbiz.cn k8s代理节点2,zk2 192.168.1.202
rstx4-203.rongbiz.cn k8s运算节点1,zk3 192.168.1.203
rstx4-204.rongbiz.cn k8s运算节点2,jenkins 192.168.1.204
rstx4-53.rongbiz.cn k8s运维节点(docker仓库) 192.168.1.53
安装jdk1.8(3台zk角色主机)
mkdir /usr/java
tar xf jdk-8u221-linux-x64.tar.gz -C /usr/java/
ln -s /usr/java/jdk1.8.0_221 /usr/java/jdk
vim /etc/profile
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
安装zookeeper(3台zk角色主机)
tar xf 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
vim /opt/zookeeper/conf/zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/data/zookeeper/data
dataLogDir=/data/zookeeper/logs
clientPort=2181
server.1=zk1.rongbiz.cn:2888:3888
server.2=zk2.rongbiz.cn:2888:3888
server.3=zk3.rongbiz.cn:2888:3888
注意:各节点zk配置相同
dns解析
zk1 A 192.168.1.201
zk2 A 192.168.1.202
zk3 A 192.168.1.203
myid
rstx4-11.rongbiz.cn上:
/data/zookeeper/data/myid
1
rstx4-12.rongbiz.cn上:
/data/zookeeper/data/myid
2
rstx4-21.rongbiz.cn上:
/data/zookeeper/data/myid
3
依次启动zookeeper
/opt/zookeeper/bin/zkServer.sh start
查看server状态
/opt/zookeeper/bin/zkServer.sh status
[root@rstx4-201 zookeeper]# /opt/zookeeper/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
Mode: follower
[root@rstx4-202 src]# /opt/zookeeper/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
Mode: leader
[root@rstx4-203 src]# /opt/zookeeper/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /opt/zookeeper/bin/../conf/zoo.cfg
Mode: follower
登录
/opt/zookeeper/bin/zkCli.sh -server localhost:2181