zookeeper简单操作命令

pfjia 2014-05-13

下面的是zookeeper的一些操作命令

帮助命令:help

[zk: 127.0.0.1:2181(CONNECTED) 2] help
ZooKeeper -server host:port cmd args
        connect host:port
        get path [watch]
        ls path [watch]
        set path data [version]
        rmr path
        delquota [-n|-b] path
        quit 
        printwatches on|off
        create [-s] [-e] path data acl
        stat path [watch]
        close 
        ls2 path [watch]
        history 
        listquota path
        setAcl path acl
        getAcl path
        sync path
        redo cmdno
        addauth scheme auth
        delete path [version]
        setquota -n|-b val path
[zk: 127.0.0.1:2181(CONNECTED) 3]

 列表命令:ls

[zk: 127.0.0.1:2181(CONNECTED) 3] ls /
[zookeeper]
[zk: 127.0.0.1:2181(CONNECTED) 4]

 创建新节点命令:create

[zk: 127.0.0.1:2181(CONNECTED) 4] create /test mydata
Created /test
[zk: 127.0.0.1:2181(CONNECTED) 5] ls /
[test, zookeeper]
[zk: 127.0.0.1:2181(CONNECTED) 6]

 获取节点get

[zk: 127.0.0.1:2181(CONNECTED) 6] get /test
mydata
cZxid = 0x12
ctime = Tue May 13 08:30:22 PDT 2014
mZxid = 0x12
mtime = Tue May 13 08:30:22 PDT 2014
pZxid = 0x12
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 6
numChildren = 0
[zk: 127.0.0.1:2181(CONNECTED) 7]

 修改set

[zk: 127.0.0.1:2181(CONNECTED) 7] set /test yunix_test
cZxid = 0x12
ctime = Tue May 13 08:30:22 PDT 2014
mZxid = 0x13
mtime = Tue May 13 08:33:45 PDT 2014
pZxid = 0x12
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 10
numChildren = 0
[zk: 127.0.0.1:2181(CONNECTED) 8] get /test
yunix_test
cZxid = 0x12
ctime = Tue May 13 08:30:22 PDT 2014
mZxid = 0x13
mtime = Tue May 13 08:33:45 PDT 2014
pZxid = 0x12
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 10
numChildren = 0
[zk: 127.0.0.1:2181(CONNECTED) 9]

 删除命令:delete

[zk: 127.0.0.1:2181(CONNECTED) 9] delete /test
[zk: 127.0.0.1:2181(CONNECTED) 10] ls /
[zookeeper]
[zk: 127.0.0.1:2181(CONNECTED) 11]

相关推荐