Zookeeper
参考
https://blog.csdn.net/qiunian144084/article/details/79192819
https://www.cnblogs.com/smail-bao/p/7009633.html
1.下载Zookeeper并解压
下载地址为:
http://zookeeper.apache.org/releases.html#download
2.在D:\GreenSoftware\zookeeper-3.4.10\conf目录下创建一个zoo.cfg文件,内容如下
tickTime=2000
dataDir=D:/GreenSoftware/zookeeper-3.4.10/data/db
dataLogDir=D:/GreenSoftware/zookeeper-3.4.10/data/log
clientPort=2181
3.启动Zookeeper
D:\GreenSoftware\zookeeper-3.4.10\bin\zkServer.cmd
4.启动客户端访问
D:\GreenSoftware\zookeeper-3.4.10\bin\zkCli.cmd -server 127.0.0.1:2181
5.基本命令
1)查看目录
ls /
2)创建节点
create /config 0
3)创建临时节点(关闭客户端时,该节点即消失)
create /server data
create -e /server/s1 127.0.0.1
ls /server
4)创建带序号的节点
create /task data
create -s /task/t_ 127.0.0.1:9000
create -s /task/t_ 127.0.0.1:9001
ls /task
5)获取节点数据
get /task
6)删除节点
delete /task/t_0000000001
7)修改节点数据
set /server/s1 127.0.0.1:80
8)监视节点变化通知(ls与get命令中)
9)领导选取
每一个客户端在/election节点下创建一个临时序列节点
create /election electionNode
create -s -e /election/e_ 127.0.0.1:9000
create -s -e /election/e_ 127.0.0.1:9001
create -s -e /election/e_ 127.0.0.1:9002
ls /election