Docker环境部署3节点zookeeper集群环境
Contents
零背景说明
需要在3台Linux机器上,部署1个zookeeper的集群环境。这里考虑通过Docker容器环境来部署。
一 环境
3台CentOS机器,OS版本和配置如下:
[root@ecs-yc165 ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) [root@ecs-yc165 ~]# free -m total used free shared buff/cache available Mem: 15884 391 14267 8 1224 15208 Swap: 0 0 0 [root@ecs-yc165 ~]# hostname -I 10.10.1.165 [root@ecs-yc165 ~]# [root@ecs-yc167 ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) [root@ecs-yc167 ~]# free -m total used free shared buff/cache available Mem: 32011 545 30245 8 1220 31118 Swap: 0 0 0 [root@ecs-yc167 ~]# hostname -I 10.10.1.167 [root@ecs-yc167 ~]# [root@ecs-yc168 ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) [root@ecs-yc168 ~]# free -m total used free shared buff/cache available Mem: 32011 540 30247 8 1224 31124 Swap: 0 0 0 [root@ecs-yc168 ~]# hostname -I 10.10.1.168 [root@ecs-yc168 ~]#
二 安装启动Docker
#1 下载安装文件 wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.9.tgz #2 解压文件 tar -zxvf docker-20.10.9.tgz #3 cp可执行文件 cp docker/* /usr/bin/ #4 创建启动配置文件/etc/systemd/system/docker.service #执行下列脚本生成文件,其中的the_host_ip改为机器实际IP地址 cat <<EOF > /etc/systemd/system/docker.service [Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewalld.service Wants=network-online.target [Service] Type=notify # the default is not to use systemd for cgroups because the delegate issues still # exists and systemd currently does not support the cgroup feature set required # for containers run by docker ExecStart=/usr/bin/dockerd --selinux-enabled=false --insecure-registry=`hostname -I` ExecReload=/bin/kill -s HUP $MAINPID # Having non-zero Limit*s causes performance problems due to accounting overhead # in the kernel. We recommend using cgroups to do container-local accounting. LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity # Uncomment TasksMax if your systemd version supports it. # Only systemd 226 and above support this version. #TasksMax=infinity TimeoutStartSec=0 # set delegate yes so that systemd does not reset the cgroups of docker containers Delegate=yes # kill only the docker process, not all processes in the cgroup KillMode=process # restart the docker process if it exits prematurely Restart=on-failure StartLimitBurst=3 StartLimitInterval=60s [Install] WantedBy=multi-user.target EOF #5 设置自动启动&启动Docker服务 #创建docker用户和组, groupadd -g 1888 docker useradd -g docker -u 1888 docker echo 'D1ng0D1888!'|passwd --stdin docker systemctl daemon-reload systemctl start docker systemctl enable docker systemctl status docker
三 配置zookeeper
1 创建配置路径
[root@ecs-yc165 data]# mkdir -p /data/zookeeper/{data,conf}
2 创建配置文件
cat <<EOF >/data/zookeeper/conf/zoo.cfg # The number of milliseconds of each tick tickTime=2000 # The number of ticks that the initial # synchronization phase can take initLimit=10 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=5 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/data/zookeeper/data/ # the port at which the clients will connect clientPort=2181 # # Be sure to read the maintenance section of the # administrator guide before turning on autopurge. # # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance # # The number of snapshots to retain in dataDir autopurge.snapRetainCount=3 # Purge task interval in hours # Set to "0" to disable auto purge feature autopurge.purgeInterval=1 server.1=10.10.1.165:2888:3888 server.2=10.10.1.167:2888:3888 server.3=10.10.1.168:2888:3888 EOF
3 创建/data/zookeeper/data/myid
[root@ecs-yc165 ~]# echo 1>/data/zookeeper/data/myid [root@ecs-yc165 ~]# cat /data/zookeeper/data/myid [root@ecs-yc165 ~]# echo 1 >/data/zookeeper/data/myid [root@ecs-yc165 ~]# cat /data/zookeeper/data/myid 1 [root@ecs-yc165 ~]#
注意:这里的第1条命令中的echo 1>/data/zookeeper/data/myid没有达到我们想要的结果,其原因是1>表示的标准输出重定向到/data/zookeeper/data/myid,表示的把空字符输出重定向到该文件。
4 启动zookeeper container
#启动container中的zookeeper的命令: docker run -d --restart unless-stopped --net=host --name="zookeeper" -e "TZ=Asia/Shanghai" -v /data/zookeeper/conf/zoo.cfg:/conf/zoo.cfg -v /data/zookeeper/data:/data/zookeeper/data -e "ZOO_MAX_CLIENT_CNXNS=3000" -e JAVA_OPTS='-Xmx4g' -e"ZOO_AUTOPURGE_PURGEINTERVAL=72" -e"ZOO_AUTOPURGE_SNAPRETAINCOUNT=160" zookeeper:3.4.11 [root@ecs-yc165 ~]# docker run -d --restart unless-stopped --net=host --name="zookeeper" -e "TZ=Asia/Shanghai" -v /data/zookeeper/conf/zoo.cfg:/conf/zoo.cfg -v /data/zookeeper/data:/data/zookeeper/data -e "ZOO_MAX_CLIENT_CNXNS=3000" -e JAVA_OPTS='-Xmx4g' -e"ZOO_AUTOPURGE_PURGEINTERVAL=72" -e"ZOO_AUTOPURGE_SNAPRETAINCOUNT=160" zookeeper:3.4.11 Unable to find image 'zookeeper:3.4.11' locally 3.4.11: Pulling from library/zookeeper ff3a5c916c92: Pull complete 5de5f69f42d7: Pull complete fa7536dd895a: Pull complete 644150d38454: Pull complete 8dd71e256b49: Pull complete 4e4fe0f19772: Pull complete 61f4a08b4d27: Pull complete Digest: sha256:b7f6fda20bee82b13abf65d760e5cbeb4c202fc1d0840d0d9fd09bac83adb181 Status: Downloaded newer image for zookeeper:3.4.11 2945b0b5bdc558752a2b796d607260ebcbf03db79c0e7bf7114d860467503c3a [root@ecs-yc165 ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2945b0b5bdc5 zookeeper:3.4.11 "/docker-entrypoint.…" 9 seconds ago Up Less than a second zookeeper [root@ecs-yc165 ~]# #启动之后会抛出下述错误,可以先忽略,因为cluster中的第2和第3个zookeeper实例还没启动 [root@ecs-yc165 zookeeper]# docker logs zookeeper ... 2022-05-05 17:23:13,454 [myid:1] - WARN [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@584] - Cannot open channel to 2 at election address /10.10.1.167:3888 java.net.ConnectException: Connection refused (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:558) at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:610) at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:845) at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:957) 2022-05-05 17:23:13,454 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer$QuorumServer@184] - Resolved hostname: 10.10.1.167 to address: /10.10.1.167 2022-05-05 17:23:13,456 [myid:1] - WARN [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumCnxManager@584] - Cannot open channel to 3 at election address /10.10.1.168:3888 java.net.ConnectException: Connection refused (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:558) at org.apache.zookeeper.server.quorum.QuorumCnxManager.connectAll(QuorumCnxManager.java:610) at org.apache.zookeeper.server.quorum.FastLeaderElection.lookForLeader(FastLeaderElection.java:845) at org.apache.zookeeper.server.quorum.QuorumPeer.run(QuorumPeer.java:957) 2022-05-05 17:23:13,457 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer$QuorumServer@184] - Resolved hostname: 10.10.1.168 to address: /10.10.1.168 2022-05-05 17:23:13,457 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@854] - Notification time out: 25600 [root@ecs-yc165 zookeeper]#
5 配置其它节点上的zookeeper,并启动container
在另外2个机器上10.10.1.167和10.10.1.68,分别重复执行上述1-4步骤。
只是分别将/data/zookeeper/data/myid 内容改写为2和3。
启动节点2上的zookeeper,看到类似下述日志:
[root@ecs-yc167 zookeeper]# docker logs -f zookeeper ... 2022-05-05 17:31:15,639 [myid:2] - INFO [LearnerHandler-/10.10.1.165:35682:LearnerHandler@401] - Synchronizing with Follower sid: 1 maxCommittedLog=0x0 minCommittedLog=0x0 peerLastZxid=0x0 2022-05-05 17:31:15,639 [myid:2] - INFO [LearnerHandler-/10.10.1.165:35682:LearnerHandler@410] - leader and follower are in sync, zxid=0x0 2022-05-05 17:31:15,639 [myid:2] - INFO [LearnerHandler-/10.10.1.165:35682:LearnerHandler@475] - Sending DIFF 2022-05-05 17:31:15,645 [myid:2] - INFO [LearnerHandler-/10.10.1.165:35682:LearnerHandler@535] - Received NEWLEADER-ACK message from 1 2022-05-05 17:31:15,645 [myid:2] - INFO [QuorumPeer[myid=2]/0:0:0:0:0:0:0:0:2181:Leader@962] - Have quorum of supporters, sids: [ 1,2 ]; starting up and setting last processed zxid: 0x100000000
启动节点3上的zookeeper,看到类似下述日志:
[root@ecs-yc168 ~]# docker logs zookeeper ZooKeeper JMX enabled by default Using config: /conf/zoo.cfg 2022-05-05 17:36:46,226 [myid:] - INFO [main:QuorumPeerConfig@136] - Reading configuration from: /conf/zoo.cfg 2022-05-05 17:36:46,236 [myid:] - INFO [main:QuorumPeer$QuorumServer@184] - Resolved hostname: 10.10.1.168 to address: /10.10.1.168 2022-05-05 17:36:46,236 [myid:] - INFO [main:QuorumPeer$QuorumServer@184] - Resolved hostname: 10.10.1.167 to address: /10.10.1.167 2022-05-05 17:36:46,237 [myid:] - INFO [main:QuorumPeer$QuorumServer@184] - Resolved hostname: 10.10.1.165 to address: /10.10.1.165 ... ... 2022-05-05 17:36:46,304 [myid:3] - INFO [WorkerReceiver[myid=3]:FastLeaderElection@602] - Notification: 1 (message format version), 2 (n.leader), 0x0 (n.zxid), 0x1 (n.round), FOLLOWING (n.state), 1 (n.sid), 0x1 (n.peerEpoch) LOOKING (my state) 2022-05-05 17:36:46,304 [myid:3] - INFO [WorkerReceiver[myid=3]:FastLeaderElection@602] - Notification: 1 (message format version), 2 (n.leader), 0x0 (n.zxid), 0x1 (n.round), LOOKING (n.state), 2 (n.sid), 0x0 (n.peerEpoch) LOOKING (my state) 2022-05-05 17:36:46,305 [myid:3] - INFO [WorkerReceiver[myid=3]:FastLeaderElection@602] - Notification: 1 (message format version), 2 (n.leader), 0x0 (n.zxid), 0x1 (n.round), LEADING (n.state), 2 (n.sid), 0x1 (n.peerEpoch) LOOKING (my state) 2022-05-05 17:36:46,305 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:QuorumPeer@979] - FOLLOWING 2022-05-05 17:36:46,308 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Learner@86] - TCP NoDelay set to: true 2022-05-05 17:36:46,311 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Environment@100] - Server environment:zookeeper.version=3.4.11-37e277162d567b55a07d1755f0b31c32e93c01a0, built on 11/01/2017 18:06 GMT 2022-05-05 17:36:46,311 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Environment@100] - Server environment:host.name=localhost 2022-05-05 17:36:46,311 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Environment@100] - Server environment:java.version=1.8.0_151 2022-05-05 17:36:46,312 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Environment@100] - Server environment:java.vendor=Oracle Corporation 2022-05-05 17:36:46,312 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Environment@100] - Server environment:java.home=/usr/lib/jvm/java-1.8-openjdk/jre 2022-05-05 17:36:46,312 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Environment@100] - Server environment:java.class.path=/zookeeper-3.4.11/bin/../build/classes:/zookeeper-3.4.11/bin/../build/lib/*.jar:/zookeeper-3.4.11/bin/../lib/slf4j-log4j12-1.6.1.jar:/zookeeper-3.4.11/bin/../lib/slf4j-api-1.6.1.jar:/zookeeper-3.4.11/bin/../lib/netty-3.10.5.Final.jar:/zookeeper-3.4.11/bin/../lib/log4j-1.2.16.jar:/zookeeper-3.4.11/bin/../lib/jline-0.9.94.jar:/zookeeper-3.4.11/bin/../lib/audience-annotations-0.5.0.jar:/zookeeper-3.4.11/bin/../zookeeper-3.4.11.jar:/zookeeper-3.4.11/bin/../src/java/lib/*.jar:/conf: 2022-05-05 17:36:46,312 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Environment@100] - Server environment:java.library.path=/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-1.8-openjdk/jre/lib/amd64:/usr/lib/jvm/java-1.8-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 2022-05-05 17:36:46,312 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Environment@100] - Server environment:java.io.tmpdir=/tmp 2022-05-05 17:36:46,312 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Environment@100] - Server environment:java.compiler=<NA> 2022-05-05 17:36:46,312 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Environment@100] - Server environment:os.name=Linux 2022-05-05 17:36:46,312 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Environment@100] - Server environment:os.arch=amd64 2022-05-05 17:36:46,312 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Environment@100] - Server environment:os.version=3.10.0-1160.53.1.el7.x86_64 2022-05-05 17:36:46,312 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Environment@100] - Server environment:user.name=zookeeper 2022-05-05 17:36:46,312 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Environment@100] - Server environment:user.home=/home/zookeeper 2022-05-05 17:36:46,312 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Environment@100] - Server environment:user.dir=/zookeeper-3.4.11 2022-05-05 17:36:46,313 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:ZooKeeperServer@173] - Created server with tickTime 2000 minSessionTimeout 4000 maxSessionTimeout 40000 datadir /data/zookeeper/data/version-2 snapdir /data/zookeeper/data/version-2 2022-05-05 17:36:46,314 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Follower@65] - FOLLOWING - LEADER ELECTION TOOK - 19 2022-05-05 17:36:46,315 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:QuorumPeer$QuorumServer@184] - Resolved hostname: 10.10.1.167 to address: /10.10.1.167 2022-05-05 17:36:46,323 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:Learner@336] - Getting a snapshot from leader 0x100000000 2022-05-05 17:36:46,326 [myid:3] - INFO [QuorumPeer[myid=3]/0:0:0:0:0:0:0:0:2181:FileTxnSnapLog@248] - Snapshotting: 0x100000000 to /data/zookeeper/data/version-2/snapshot.100000000 [root@ecs-yc168 ~]#
6 验证zookeeper的集群
10.10.1.165机器执行:
进入Docker内部,通过zkCli.sh连接到10.10.1.167:2181,创建path /zk_znode_1
[root@ecs-yc165 data]# docker exec -it zookeeper /bin/bash bash-4.4# ls LICENSE.txt bin dist-maven lib zookeeper-3.4.11.jar.asc NOTICE.txt build.xml docs recipes zookeeper-3.4.11.jar.md5 README.md conf ivy.xml src zookeeper-3.4.11.jar.sha1 README_packaging.txt contrib ivysettings.xml zookeeper-3.4.11.jar bash-4.4# ls bin README.txt zkCleanup.sh zkCli.cmd zkCli.sh zkEnv.cmd zkEnv.sh zkServer.cmd zkServer.sh bash-4.4# cd bin/ bash-4.4# ls README.txt zkCleanup.sh zkCli.cmd zkCli.sh zkEnv.cmd zkEnv.sh zkServer.cmd zkServer.sh bash-4.4# ./zkCli.sh -server 10.10.1.167:2181 Connecting to 10.10.1.167:2181 2022-05-05 17:42:39,394 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.11-37e277162d567b55a07d1755f0b31c32e93c01a0, built on 11/01/2017 18:06 GMT ... WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: 10.10.1.167:2181(CONNECTED) 0] ls / [zookeeper] [zk: 10.10.1.167:2181(CONNECTED) 1] create /zk_znode_1 sample_data Created /zk_znode_1 [zk: 10.10.1.167:2181(CONNECTED) 2] ls / [zk_znode_1, zookeeper] [zk: 10.10.1.167:2181(CONNECTED) 3] get /z zk_znode_1 zookeeper [zk: 10.10.1.167:2181(CONNECTED) 3] get /zk_znode_1 sample_data cZxid = 0x100000002 ctime = Thu May 05 17:43:58 CST 2022 mZxid = 0x100000002 mtime = Thu May 05 17:43:58 CST 2022 pZxid = 0x100000002 cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 11 numChildren = 0 [zk: 10.10.1.167:2181(CONNECTED) 4]
10.10.1.168机器执行:
进入Docker内部,通过zkCli.sh连接到10.10.1.165:2181,查看并删除 path /zk_znode_1
[root@ecs-yc168 version-2]# docker exec -it zookeeper /bin/bash bash-4.4# cd bin/ bash-4.4# ./zkCli.sh #先连接本机zookeeper,查看 Connecting to localhost:2181 2022-05-05 17:46:10,334 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.11-37e277162d567b55a07d1755f0b31c32e93c01a0, built on 11/01/2017 18:06 GMT 2022-05-05 17:46:10,337 [myid:] - INFO [main:Environment@100] - Client environment:host.name=localhost 2022-05-05 17:46:10,337 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_151 2022-05-05 17:46:10,339 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation 2022-05-05 17:46:10,340 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/usr/lib/jvm/java-1.8-openjdk/jre ... [zk: localhost:2181(CONNECTED) 1] ls / [zk_znode_1, zookeeper] [zk: localhost:2181(CONNECTED) 2] ls /zk_znode_1 [] [zk: localhost:2181(CONNECTED) 3] get /zk_znode_1 sample_data cZxid = 0x100000002 ctime = Thu May 05 17:43:58 CST 2022 mZxid = 0x100000002 mtime = Thu May 05 17:43:58 CST 2022 pZxid = 0x100000002 cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 11 numChildren = 0 [zk: localhost:2181(CONNECTED) 4] quit Quitting... 2022-05-05 17:46:34,781 [myid:] - INFO [main:ZooKeeper@687] - Session: 0x3000195c6570000 closed 2022-05-05 17:46:34,783 [myid:] - INFO [main-EventThread:ClientCnxn$EventThread@520] - EventThread shut down for session: 0x3000195c6570000 bash-4.4# ./zkCli.sh -server 10.10.1.165:2181 #连接-server 10.10.1.165:2181 Connecting to 10.10.1.165:2181 2022-05-05 17:47:11,909 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.11-37e277162d567b55a07d1755f0b31c32e93c01a0, built on 11/01/2017 18:06 GMT 2022-05-05 17:47:11,912 [myid:] - INFO [main:Environment@100] - Client environment:host.name=localhost 2022-05-05 17:47:11,912 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_151 2022-05-05 17:47:11,915 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation 2022-05-05 17:47:11,915 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/usr/lib/jvm/java-1.8-openjdk/jre ... WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: 10.10.1.165:2181(CONNECTED) 0] ls / [zk_znode_1, zookeeper] [zk: 10.10.1.165:2181(CONNECTED) 1] get /zk_znode_1 sample_data cZxid = 0x100000002 ctime = Thu May 05 17:43:58 CST 2022 mZxid = 0x100000002 mtime = Thu May 05 17:43:58 CST 2022 pZxid = 0x100000002 cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 11 numChildren = 0 [zk: 10.10.1.165:2181(CONNECTED) 2] [zk: 10.10.1.165:2181(CONNECTED) 2] del delquota delete [zk: 10.10.1.165:2181(CONNECTED) 2] delete /zk_znode_1 [zk: 10.10.1.165:2181(CONNECTED) 3]
最后,再到其它zookeeper的节点上查看,发现/zk_znode_1被删除了。
至此,完成了zookeeper的集群配置和验证。