键入help,可以看到有如下命令:
connecthost:port getpath [watch] lspath [watch] setpath data [version] rmrpath delquota[-n|-b] path quit printwatcheson|off create[-s] [-e] path data acl statpath [watch] close ls2path [watch] history listquotapath setAclpath acl getAclpath syncpath redocmdno addauthscheme auth deletepath [version] setquota-n|-b val path
首先,看看列表命令,如下:
[zk: 127.0.0.1:2181(CONNECTED) 6] ls / [zookeeper]
[zk: 127.0.0.1:2181(CONNECTED) 6] create/zk_test my_data Created /zk_test
[zk: 127.0.0.1:2181(CONNECTED) 6] ls / [zookeeper, zk_test]
下面,我们使用get命令来验证此znode节点相关的数据,如下:
[zk: 127.0.0.1:2181(CONNECTED) 7] get/zk_test my_data cZxid = 0x4 ctime = Fri May 02 08:28:40 UTC 2014 mZxid = 0x4 mtime = Fri May 02 08:28:40 UTC 2014 pZxid = 0x4 cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 7 numChildren = 0
[zk: 127.0.0.1:2181(CONNECTED) 8] set/zk_test junk cZxid = 0x4 ctime = Fri May 02 08:28:40 UTC 2014 mZxid = 0x5 mtime = Fri May 02 08:34:32 UTC 2014 pZxid = 0x4 cversion = 0 dataVersion = 1 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 4 numChildren = 0
[zk: 127.0.0.1:2181(CONNECTED) 10] delete/zk_test [zk: 127.0.0.1:2181(CONNECTED) 11] ls / [zookeeper]
[zk: 127.0.0.1:2181(CONNECTED) 12] quit Quitting... 2014-05-02 08:49:47,415 [myid:] - INFO [main:ZooKeeper@684] - Session:0x145bbdc9b460001 closed 2014-05-02 08:49:47,415 [myid:] - INFO [main-EventThread:ClientCnxn$EventThread@512]- EventThread shut down