zookeeper简单命令

1. 连接到zookeeper服务

[root@iiot-test-server1 bin]# sh zkCli.sh -server 127.0.0.1:2181

2. ls命令查看

[zk: 127.0.0.1:2181(CONNECTED) 0] ls /
[newconnector1, manager, manager1, clusterstate.json, YINSHI.MONITOR.ALIVE.CHECK, upload, newconfig, configs, newmanager, newconnector11, hbase, newconnector, zookeeper, aliases.json, connector, config, live_nodes, overseer, overseer_elect, collections]

3. create命令创建节点

[zk: 127.0.0.1:2181(CONNECTED) 0]create /zk testData 
Created
/zk

4.  获取节点中的值  get命令

[zk:127.0.0.1:2181(CONNECTED) 4] get /zk
testData
cZxid = 0x700000008
ctime = Sat Mar 0923:01:24 CST 2013
mZxid = 0x700000008
mtime = Sat Mar 0923:01:24 CST 2013
pZxid = 0x700000008
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 8
numChildren = 0

5.  set命令设置

[zk: 127.0.0.1:2181(CONNECTED) 5] set /zk mydata
cZxid = 0x700000008
ctime = Sat Mar 09 23:01:24 CST 2013
mZxid = 0x700000009
mtime = Sat Mar 09 23:06:03 CST 2013
pZxid = 0x700000008
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 6
numChildren = 0

6.  删除znode节点

[zk: 127.0.0.1:2181(CONNECTED) 7]delete /zk

 

posted @ 2015-09-06 14:41  huonan  阅读(366)  评论(0编辑  收藏  举报