zookeeper中client命令实践
Welcome to ZooKeeper! 2016-09-14 16:06:04,528 [myid:] - INFO [main-SendThread(master:2181):ClientCnxn $SendThread@1032] - Opening socket connection to server master/192.168.137.10:21 81. Will not attempt to authenticate using SASL (unknown error) 2016-09-14 16:06:04,529 [myid:] - INFO [main-SendThread(master:2181):ClientCnxn $SendThread@876] - Socket connection established to master/192.168.137.10:2181, initiating session JLine support is enabled 2016-09-14 16:06:04,537 [myid:] - INFO [main-SendThread(master:2181):ClientCnxn $SendThread@1299] - Session establishment complete on server master/192.168.137. 10:2181, sessionid = 0x1572664a952000b, negotiated timeout = 30000 WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: master:2181(CONNECTED) 12] help ZooKeeper -server host:port cmd args stat path [watch] set path data [version] ls path [watch] delquota [-n|-b] path ls2 path [watch] setAcl path acl setquota -n|-b val path history redo cmdno printwatches on|off delete path [version] sync path listquota path rmr path get path [watch] create [-s] [-e] path data acl addauth scheme auth quit getAcl path close connect host:port [zk: master:2181(CONNECTED) 0] ls / [zookeeper] [zk: master:2181(CONNECTED) 0] create -s -e /felixzh ok Created /felixzh0000000005 [zk: master:2181(CONNECTED) 1] ls / [felixzh0000000005, zookeeper] [zk: master:2181(CONNECTED) 2] create -s -e /felix Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4 at org.apache.zookeeper.ZooKeeperMain.processZKCmd(ZooKeeperMain.java:70 6) at org.apache.zookeeper.ZooKeeperMain.processCmd(ZooKeeperMain.java:599) at org.apache.zookeeper.ZooKeeperMain.executeLine(ZooKeeperMain.java:371 ) at org.apache.zookeeper.ZooKeeperMain.run(ZooKeeperMain.java:331) at org.apache.zookeeper.ZooKeeperMain.main(ZooKeeperMain.java:290) [zk: master:2181(CONNECTED) 0] ls / [zookeeper] [zk: master:2181(CONNECTED) 1] create -s felix Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3 at org.apache.zookeeper.ZooKeeperMain.processZKCmd(ZooKeeperMain.java:70 6) at org.apache.zookeeper.ZooKeeperMain.processCmd(ZooKeeperMain.java:599) at org.apache.zookeeper.ZooKeeperMain.executeLine(ZooKeeperMain.java:371 ) at org.apache.zookeeper.ZooKeeperMain.run(ZooKeeperMain.java:331) at org.apache.zookeeper.ZooKeeperMain.main(ZooKeeperMain.java:290) [zk: master:2181(CONNECTED) 0] ls / [zookeeper] [zk: master:2181(CONNECTED) 1] create -e felix Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3 at org.apache.zookeeper.ZooKeeperMain.processZKCmd(ZooKeeperMain.java:70 6) at org.apache.zookeeper.ZooKeeperMain.processCmd(ZooKeeperMain.java:599) at org.apache.zookeeper.ZooKeeperMain.executeLine(ZooKeeperMain.java:371 ) at org.apache.zookeeper.ZooKeeperMain.run(ZooKeeperMain.java:331) at org.apache.zookeeper.ZooKeeperMain.main(ZooKeeperMain.java:290) WatchedEvent state:SyncConnected type:None path:null [zk: master:2181(CONNECTED) 0] ls / [zookeeper] [zk: master:2181(CONNECTED) 1] create felix [zk: master:2181(CONNECTED) 2] ls / [zookeeper] [zk: master:2181(CONNECTED) 3] get felix Command failed: java.lang.IllegalArgumentException: Path must start with / chara cter [zk: master:2181(CONNECTED) 4] get /felix Node does not exist: /felix [zk: master:2181(CONNECTED) 0] ls / [zookeeper] [zk: master:2181(CONNECTED) 1] create felix [zk: master:2181(CONNECTED) 2] ls / [zookeeper] [zk: master:2181(CONNECTED) 3] get felix Command failed: java.lang.IllegalArgumentException: Path must start with / chara cter [zk: master:2181(CONNECTED) 4] get /felix Node does not exist: /felix [zk: master:2181(CONNECTED) 5] create -s -e /felix ok Created /felix0000000006 [zk: master:2181(CONNECTED) 6] create -s /felix ok Created /felix0000000007 [zk: master:2181(CONNECTED) 7] create -e /felix ok Created /felix [zk: master:2181(CONNECTED) 8] ls / [felix0000000007, felix, felix0000000006, zookeeper] [zk: master:2181(CONNECTED) 0] ls / [felix0000000007, zookeeper] [zk: master:2181(CONNECTED) 1] get /felix0000000007 ok cZxid = 0x700000034 ctime = Wed Sep 14 16:14:46 CST 2016 mZxid = 0x700000034 mtime = Wed Sep 14 16:14:46 CST 2016 pZxid = 0x700000034 cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 2 numChildren = 0 [zk: master:2181(CONNECTED) 2] set /felix0000000007 no cZxid = 0x700000034 ctime = Wed Sep 14 16:14:46 CST 2016 mZxid = 0x700000038 mtime = Wed Sep 14 16:17:15 CST 2016 pZxid = 0x700000034 cversion = 0 dataVersion = 1 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 2 numChildren = 0 [zk: master:2181(CONNECTED) 3] get /felix0000000007 no cZxid = 0x700000034 ctime = Wed Sep 14 16:14:46 CST 2016 mZxid = 0x700000038 mtime = Wed Sep 14 16:17:15 CST 2016 pZxid = 0x700000034 cversion = 0 dataVersion = 1 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 2 numChildren = 0 [zk: master:2181(CONNECTED) 3] ls / [felix0000000007, zookeeper] [zk: master:2181(CONNECTED) 4] create /felix0000000007/son ok Created /felix0000000007/son [zk: master:2181(CONNECTED) 5] ls / [felix0000000007, zookeeper] [zk: master:2181(CONNECTED) 6] ls /felix0000000007 [son] [zk: master:2181(CONNECTED) 7] rmr /felix0000000007 [zk: master:2181(CONNECTED) 8] ls / [zookeeper] [zk: master:2181(CONNECTED) 9] close 2016-09-14 16:32:33,116 [myid:] - INFO [main:ZooKeeper@684] - Session: 0x157266 4a9520011 closed 2016-09-14 16:32:33,117 [myid:] - INFO [main-EventThread:ClientCnxn$EventThread @519] - EventThread shut down for session: 0x1572664a9520011 [zk: master:2181(CLOSED) 10] connect master:2181 2016-09-14 16:32:48,843 [myid:] - INFO [main:ZooKeeper@438] - Initiating client connection, connectString=master:2181 sessionTimeout=30000 watcher=org.apache.z ookeeper.ZooKeeperMain$MyWatcher@3c679bde [zk: master:2181(CONNECTING) 11] 2016-09-14 16:32:48,847 [myid:] - INFO [main-S endThread(master:2181):ClientCnxn$SendThread@1032] - Opening socket connection t o server master/192.168.137.10:2181. Will not attempt to authenticate using SASL (unknown error) 2016-09-14 16:32:48,848 [myid:] - INFO [main-SendThread(master:2181):ClientCnxn $SendThread@876] - Socket connection established to master/192.168.137.10:2181, initiating session 2016-09-14 16:32:48,851 [myid:] - INFO [main-SendThread(master:2181):ClientCnxn $SendThread@1299] - Session establishment complete on server master/192.168.137. 10:2181, sessionid = 0x1572664a9520012, negotiated timeout = 30000 WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: master:2181(CONNECTED) 11] [zk: master:2181(CONNECTED) 11] history 1 - ls /felix0000000007 2 - get /felix0000000007 3 - ls / 4 - create /felix0000000007/son ok 5 - ls / 6 - ls /felix0000000007 7 - rmr /felix0000000007 8 - ls / 9 - close 10 - connect master:2181 11 - history [zk: master:2181(CONNECTED) 23] ls / [zookeeper] [zk: master:2181(CONNECTED) 24] create -s /felix ok Created /felix0000000010 [zk: master:2181(CONNECTED) 25] create /felix/son ok Node does not exist: /felix/son [zk: master:2181(CONNECTED) 26] create /felix0000000010/son ok Created /felix0000000010/son [zk: master:2181(CONNECTED) 27] ls / [felix0000000010, zookeeper] [zk: master:2181(CONNECTED) 28] ls /felix0000000010 [son] [zk: master:2181(CONNECTED) 29] delete /felix0000000010 Node not empty: /felix0000000010 [zk: master:2181(CONNECTED) 30] delete /felix0000000010/son [zk: master:2181(CONNECTED) 31] delete /felix0000000010 [zk: master:2181(CONNECTED) 34] ls / [zookeeper] [zk: master:2181(CONNECTED) 35] create /felix ok Created /felix [zk: master:2181(CONNECTED) 36] set /felix okok cZxid = 0x70000004a ctime = Wed Sep 14 16:45:39 CST 2016 mZxid = 0x70000004b mtime = Wed Sep 14 16:45:47 CST 2016 pZxid = 0x70000004a cversion = 0 dataVersion = 1 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 4 numChildren = 0 [zk: master:2181(CONNECTED) 37] get /felix okok cZxid = 0x70000004a ctime = Wed Sep 14 16:45:39 CST 2016 mZxid = 0x70000004b mtime = Wed Sep 14 16:45:47 CST 2016 pZxid = 0x70000004a cversion = 0 dataVersion = 1 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 4 numChildren = 0 [zk: master:2181(CONNECTED) 38] delete /felix 0 version No is not valid : /felix [zk: master:2181(CONNECTED) 39] delete /felix 1 [zk: master:2181(CONNECTED) 40] get /felix Node does not exist: /felix [zk: master:2181(CONNECTED) 41] ls / [zookeeper] [zk: master:2181(CONNECTED) 42] create /felix ok Created /felix [zk: master:2181(CONNECTED) 43] set /felix okok cZxid = 0x70000004e ctime = Wed Sep 14 16:48:05 CST 2016 mZxid = 0x70000004f mtime = Wed Sep 14 16:48:15 CST 2016 pZxid = 0x70000004e cversion = 0 dataVersion = 1 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 4 numChildren = 0 [zk: master:2181(CONNECTED) 44] set /felix okokok cZxid = 0x70000004e ctime = Wed Sep 14 16:48:05 CST 2016 mZxid = 0x700000050 mtime = Wed Sep 14 16:48:21 CST 2016 pZxid = 0x70000004e cversion = 0 dataVersion = 2 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 6 numChildren = 0 [zk: master:2181(CONNECTED) 45] delete /felix 1 version No is not valid : /felix [zk: master:2181(CONNECTED) 46] delete /felix 0 version No is not valid : /felix [zk: master:2181(CONNECTED) 47] delete /felix [zk: master:2181(CONNECTED) 48] get /felix Node does not exist: /felix [zk: master:2181(CONNECTED) 49] create -s /felix ok Created /felix0000000013 [zk: master:2181(CONNECTED) 50] set /felix0000000013 okok cZxid = 0x700000054 ctime = Wed Sep 14 16:50:27 CST 2016 mZxid = 0x700000055 mtime = Wed Sep 14 16:51:04 CST 2016 pZxid = 0x700000054 cversion = 0 dataVersion = 1 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 4 numChildren = 0 [zk: master:2181(CONNECTED) 51] delete /felix0000000013 0 version No is not valid : /felix0000000013 [zk: master:2181(CONNECTED) 52] delete /felix0000000013 1 [zk: master:2181(CONNECTED) 53] ls / [zookeeper] [zk: master:2181(CONNECTED) 54] 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 = 0x700000057 cversion = 27 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 0 numChildren = 1 [zk: master:2181(CONNECTED) 55] create -s /felix ok Created /felix0000000014 [zk: master:2181(CONNECTED) 56] ls / [zookeeper, felix0000000014] [zk: master:2181(CONNECTED) 57] ls2 / [zookeeper, felix0000000014] cZxid = 0x0 ctime = Thu Jan 01 08:00:00 CST 1970 mZxid = 0x0 mtime = Thu Jan 01 08:00:00 CST 1970 pZxid = 0x700000058 cversion = 28 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 0 numChildren = 2 [zk: master:2181(CONNECTED) 58] printwatches printwatches is on [zk: master:2181(CONNECTED) 59] printwatches off [zk: master:2181(CONNECTED) 60] printwatches printwatches is off [zk: master:2181(CONNECTED) 61] printwatches on [zk: master:2181(CONNECTED) 62] printwatches printwatches is on [zk: master:2181(CONNECTED) 66] ls2 /felix0000000014 [] cZxid = 0x700000058 ctime = Wed Sep 14 16:53:26 CST 2016 mZxid = 0x700000058 mtime = Wed Sep 14 16:53:26 CST 2016 pZxid = 0x700000058 cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 2 numChildren = 0 [zk: master:2181(CONNECTED) 67] ls2 /felix0000000014 on [] cZxid = 0x700000058 ctime = Wed Sep 14 16:53:26 CST 2016 mZxid = 0x700000058 mtime = Wed Sep 14 16:53:26 CST 2016 pZxid = 0x700000058 cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 2 numChildren = 0 [zk: master:2181(CONNECTED) 68] ls2 /felix0000000014 off [] cZxid = 0x700000058 ctime = Wed Sep 14 16:53:26 CST 2016 mZxid = 0x700000058 mtime = Wed Sep 14 16:53:26 CST 2016 pZxid = 0x700000058 cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 2 numChildren = 0 [zk: master:2181(CONNECTED) 69] stat /felix0000000014 on cZxid = 0x700000058 ctime = Wed Sep 14 16:53:26 CST 2016 mZxid = 0x700000058 mtime = Wed Sep 14 16:53:26 CST 2016 pZxid = 0x700000058 cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 2 numChildren = 0 [zk: master:2181(CONNECTED) 70] stat /felix0000000014 off cZxid = 0x700000058 ctime = Wed Sep 14 16:53:26 CST 2016 mZxid = 0x700000058 mtime = Wed Sep 14 16:53:26 CST 2016 pZxid = 0x700000058 cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 2 numChildren = 0 [zk: master:2181(CONNECTED) 71] ls / [zookeeper, felix0000000014] [zk: master:2181(CONNECTED) 72] getAcl /felix0000000014 'world,'anyone : cdrwa [zk: master:2181(CONNECTED) 73] create /felix ok Created /felix [zk: master:2181(CONNECTED) 74] set set setAcl setquota [zk: master:2181(CONNECTED) 74] setAcl /felix digest:user:passwd:r cZxid = 0x700000059 ctime = Wed Sep 14 17:25:04 CST 2016 mZxid = 0x700000059 mtime = Wed Sep 14 17:25:04 CST 2016 pZxid = 0x700000059 cversion = 0 dataVersion = 0 aclVersion = 1 ephemeralOwner = 0x0 dataLength = 2 numChildren = 0 [zk: master:2181(CONNECTED) 75] getAcl /felix 'digest,'user:passwd : r [zk: master:2181(CONNECTED) 76] get /felix Authentication is not valid : /felix [zk: master:2181(CONNECTED) 77] addauth digest user:passwd [zk: master:2181(CONNECTED) 78] get /felix Authentication is not valid : /felix [zk: master:2181(CONNECTED) 79] addauth /felix digest user:passwd [zk: master:2181(CONNECTED) 80] WATCHER:: WatchedEvent state:AuthFailed type:None path:null [zk: master:2181(AUTH_FAILED) 80] get /felix Not connected [zk: master:2181(AUTH_FAILED) 81] connect master:2181 2016-09-14 17:34:10,430 [myid:] - INFO [main:ZooKeeper@438] - Initiating client connection, connectString=master:2181 sessionTimeout=30000 watcher=org.apache.z ookeeper.ZooKeeperMain$MyWatcher@12bc6874 [zk: master:2181(CONNECTING) 82] 2016-09-14 17:34:10,432 [myid:] - INFO [main-S endThread(master:2181):ClientCnxn$SendThread@1032] - Opening socket connection t o server master/192.168.137.10:2181. Will not attempt to authenticate using SASL (unknown error) 2016-09-14 17:34:10,432 [myid:] - INFO [main-SendThread(master:2181):ClientCnxn $SendThread@876] - Socket connection established to master/192.168.137.10:2181, initiating session 2016-09-14 17:34:10,436 [myid:] - INFO [main-SendThread(master:2181):ClientCnxn $SendThread@1299] - Session establishment complete on server master/192.168.137. 10:2181, sessionid = 0x1572664a9520013, negotiated timeout = 30000 WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: master:2181(CONNECTED) 82] get /felix Authentication is not valid : /felix [zk: master:2181(CONNECTED) 83] addauth /felix digest user:passwd [zk: master:2181(CONNECTED) 84] WATCHER:: WatchedEvent state:AuthFailed type:None path:null [zk: master:2181(AUTH_FAILED) 84] connect master:2181 2016-09-14 17:34:39,259 [myid:] - INFO [main:ZooKeeper@438] - Initiating client connection, connectString=master:2181 sessionTimeout=30000 watcher=org.apache.z ookeeper.ZooKeeperMain$MyWatcher@de0a01f [zk: master:2181(CONNECTING) 85] 2016-09-14 17:34:39,261 [myid:] - INFO [main-S endThread(master:2181):ClientCnxn$SendThread@1032] - Opening socket connection t o server master/192.168.137.10:2181. Will not attempt to authenticate using SASL (unknown error) 2016-09-14 17:34:39,261 [myid:] - INFO [main-SendThread(master:2181):ClientCnxn $SendThread@876] - Socket connection established to master/192.168.137.10:2181, initiating session 2016-09-14 17:34:39,277 [myid:] - INFO [main-SendThread(master:2181):ClientCnxn $SendThread@1299] - Session establishment complete on server master/192.168.137. 10:2181, sessionid = 0x1572664a9520014, negotiated timeout = 30000 WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: master:2181(CONNECTED) 85] addauth digest user:passwd [zk: master:2181(CONNECTED) 86] get /felix Authentication is not valid : /felix [zk: master:2181(CONNECTED) 88] ls / [felix, zookeeper, felix0000000014] [zk: master:2181(CONNECTED) 89] getAcl /felix 'digest,'user:passwd : r [zk: master:2181(CONNECTED) 90] addauth digest:user:passwd [zk: master:2181(CONNECTED) 91] WATCHER:: WatchedEvent state:AuthFailed type:None path:null [zk: master:2181(AUTH_FAILED) 91] connect master:2181 2016-09-14 17:38:12,741 [myid:] - INFO [main:ZooKeeper@438] - Initiating client connection, connectString=master:2181 sessionTimeout=30000 watcher=org.apache.z ookeeper.ZooKeeperMain$MyWatcher@1ef7fe8e [zk: master:2181(CONNECTING) 92] 2016-09-14 17:38:12,743 [myid:] - INFO [main-S endThread(master:2181):ClientCnxn$SendThread@1032] - Opening socket connection t o server master/192.168.137.10:2181. Will not attempt to authenticate using SASL (unknown error) 2016-09-14 17:38:12,744 [myid:] - INFO [main-SendThread(master:2181):ClientCnxn $SendThread@876] - Socket connection established to master/192.168.137.10:2181, initiating session 2016-09-14 17:38:12,747 [myid:] - INFO [main-SendThread(master:2181):ClientCnxn $SendThread@1299] - Session establishment complete on server master/192.168.137. 10:2181, sessionid = 0x1572664a9520016, negotiated timeout = 30000 WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: master:2181(CONNECTED) 92] addauth digest user:passwd [zk: master:2181(CONNECTED) 93] delete /felix [zk: master:2181(CONNECTED) 94] ls / [zookeeper, felix0000000014]
欢迎关注微信公众号:大数据从业者