Zookeeper客户端命令行操作
zookeeper节点类型(持久/短暂/有序号/无序号)
持久:客户端和服务端断开连接后 创建的节点不删除
代码语言:javascript复制创建持久节点 create /yingxiong "daomei"
创建带序号的持久节点
代码语言:javascript复制[zk: localhost:2181(CONNECTED) 14] create -s /yinxiong "feileier"
Created /yinxiong0000000001
短暂:客户端和服务端断开连接后,创建的节点自己删除
代码语言:javascript复制zk: localhost:2181(CONNECTED) 5] create -e /yingxiong "zhumei"
zk: localhost:2181(CONNECTED) 5] create -e -s /yingxiong "zhumei" 带序号的
监听节点值的变化
代码语言:javascript复制get -w /yingxiong
注意 :注册一次生效一次 想多次生效就要注册多次
节点的删除与查看
代码语言:javascript复制删除节点
delete /yingxiong/lianmeng
递归删除节点
deleteall /yingxiong/lianmeng
[zk: localhost:2181(CONNECTED) 9] deleteall /yingxiong
[zk: localhost:2181(CONNECTED) 10] ls /yingxiong
Node does not exist: /yingxiong
查看节点状态
stat /yingxiong
[zk: localhost:2181(CONNECTED) 16] stat /yinxiong0000000001
cZxid = 0x13
ctime = Tue Sep 14 09:15:20 CST 2021
mZxid = 0x13
mtime = Tue Sep 14 09:15:20 CST 2021
pZxid = 0x13
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 8
numChildren = 0