zookeeper分布式安装教程
-
手动到官网下载然后上传到服务器!https://zookeeper.apache.org/releases.html(单机版可参考上一篇zookeeper单机版安装教程)
-
解压安装包
tar -xvf apache-zookeeper-3.5.9-bin.tar.gz -C /home/software
-
在conf目录下配置zoo.cfg文件
# 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=/home/software/apache-zookeeper-3.5.9-bin/zkData #事务日志文件目录(存储快照的目录) # the port at which the clients will connect clientPort=2181 # the maximum number of client connections. # increase this if you need to handle more clients #maxClientCnxns=60 # # 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.1.48.216:2888:3888 server.2=10.1.48.217:2888:3888 server.3=10.1.48.218:2888:3888 #四字白名单防止信息泄露,默认开启 4lw.commands.whitelist=*
-
创建dataDir
#在apache-zookeeper-3.5.9-bin目录下 mkdir zkData cd zkData vi myid #对应上面集群配置的序号,以此递推 1 #就只写入序号
-
将内容分发到其他的节点
scp -r apache-zookeeper-3.5.9-bin root@10.1.48.217:/home/software/ scp -r apache-zookeeper-3.5.9-bin root@10.1.48.218:/home/software/ #分发结束后注意修改dataDir目录下的myid
-
启动、关闭、查看状态等命令
#在bin目录下执行 sh zkServer.sh status #查看状态 sh zkServer.sh start #启动zookeeper sh zkServer.sh stop #关闭zookeeper ./zkServer.sh restart #重启zookeeper
-
远程命令
[root@k8smaster01 bin]# echo conf | nc 10.1.48.216 2181 #查看conf clientPort=2181 secureClientPort=-1 dataDir=/home/software/apache-zookeeper-3.5.9-bin/zkData/version-2 dataDirSize=67109868 dataLogDir=/home/software/apache-zookeeper-3.5.9-bin/zkData/version-2 dataLogSize=67109868 tickTime=2000 maxClientCnxns=60 minSessionTimeout=4000 maxSessionTimeout=40000 serverId=1 initLimit=10 syncLimit=5 electionAlg=3 electionPort=3888 quorumPort=2888 peerType=0 membership: server.1=10.1.48.216:2888:3888:participant server.2=10.1.48.217:2888:3888:participant server.3=10.1.48.218:2888:3888:participant
[root@k8smaster01 bin]# echo stat | nc 10.1.48.216 2181 #查看状态 Zookeeper version: 3.5.9-83df9301aa5c2a5d284a9940177808c01bc35cef, built on 01/06/2021 19:49 GMT Clients: /10.1.48.216:55424[0](queued=0,recved=1,sent=0) Latency min/avg/max: 0/0/0 Received: 4 Sent: 3 Connections: 1 Outstanding: 0 Zxid: 0x6 Mode: follower Node count: 5
[root@k8smaster01 bin]# echo ruok | nc 10.1.48.217 2181 #查看其他节点是否存活 imok #表示存活 [root@k8smaster01 bin]# echo ruok | nc 10.1.48.218 2181 Ncat: Connection refused. #表示不存活
脚踏实地,注重基础。