zookeeper命令行操作

/ Linux_manage / 没有评论 / 802浏览

ls

[zk: localhost:2181(CONNECTED) 7] ls /
[zookeeper]

ls命令查询当前节点下的子节点

ls2

[zk: localhost:2181(CONNECTED) 9] ls2 /
[zookeeper]
cZxid = 0x0
ctime = Thu Jan 01 08:00:00 CST 1970
mZxid = 0x0
mtime = Thu Jan 01 08:00:00 CST 1970
pZxid = 0x0
cversion = -1
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 0
numChildren = 1

ls2命令是查询当前节点的所有信息,是ls+stat命令的组合效果

stat

stat命令查询当前节点信息

[zk: localhost:2181(CONNECTED) 11] stat /
cZxid = 0x0
ctime = Thu Jan 01 08:00:00 CST 1970
mZxid = 0x0
mtime = Thu Jan 01 08:00:00 CST 1970
pZxid = 0x0
cversion = -1
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 0
numChildren = 1

get

确认是否包含我们所创建的字符串

[zk: localhost:2181(CONNECTED) 10] get /

cZxid = 0x0
ctime = Thu Jan 01 08:00:00 CST 1970
mZxid = 0x0
mtime = Thu Jan 01 08:00:00 CST 1970
pZxid = 0x0
cversion = -1
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 0
numChildren = 1

set

更新节点数据,对 zk 所关联的字符串进行设置

root@paa2:/usr/local/zookeeper/bin# echo conf |nc 192.168.0.166 2181
clientPort=2181
dataDir=/usr/local/zookeeper/data/version-2
dataLogDir=/usr/local/zookeeper/data/version-2
tickTime=2000
maxClientCnxns=60
minSessionTimeout=4000
maxSessionTimeout=40000
serverId=3
initLimit=10
syncLimit=5
electionAlg=3
electionPort=3888
quorumPort=2888
peerType=0

四字命令

示范

root@paa2:/usr/local/zookeeper/bin# echo conf |nc 192.168.0.166 2181
clientPort=2181
dataDir=/usr/local/zookeeper/data/version-2
dataLogDir=/usr/local/zookeeper/data/version-2
tickTime=2000
maxClientCnxns=60
minSessionTimeout=4000
maxSessionTimeout=40000
serverId=3
initLimit=10
syncLimit=5
electionAlg=3
electionPort=3888
quorumPort=2888
peerType=0