zookeeper 数据节点的增删改查
1、连接服务端
[root@localhost bin]# ./zkCli.sh -server 127.0.0.1:2181 Connecting to 127.0.0.1:2181 2018-05-24 13:42:35,463 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.12-e5259e437540f349646870ea94dc2658c4e44b3b, built on 03/27/2018 03:55 GMT 2018-05-24 13:42:35,469 [myid:] - INFO [main:Environment@100] - Client environment:host.name=localhost 2018-05-24 13:42:35,469 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_172 2018-05-24 13:42:35,482 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation 2018-05-24 13:42:35,482 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/mirana/software/jdk1.8/jre 2018-05-24 13:42:35,482 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/mirana/software/zookeeper/zk03/bin/../build/classes:/mirana/software/zookeeper/zk03/bin/../build/lib/*.jar:/mirana/software/zookeeper/zk03/bin/../lib/slf4j-log4j12-1.7.25.jar:/mirana/software/zookeeper/zk03/bin/../lib/slf4j-api-1.7.25.jar:/mirana/software/zookeeper/zk03/bin/../lib/netty-3.10.6.Final.jar:/mirana/software/zookeeper/zk03/bin/../lib/log4j-1.2.17.jar:/mirana/software/zookeeper/zk03/bin/../lib/jline-0.9.94.jar:/mirana/software/zookeeper/zk03/bin/../lib/audience-annotations-0.5.0.jar:/mirana/software/zookeeper/zk03/bin/../zookeeper-3.4.12.jar:/mirana/software/zookeeper/zk03/bin/../src/java/lib/*.jar:/mirana/software/zookeeper/zk03/bin/../conf:/mirana/software/jdk1.8/jre/lib/rt.jar:/mirana/software/jdk1.8/jre/lib/ext 2018-05-24 13:42:35,482 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 2018-05-24 13:42:35,482 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp 2018-05-24 13:42:35,482 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=<NA> 2018-05-24 13:42:35,483 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux 2018-05-24 13:42:35,483 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64 2018-05-24 13:42:35,483 [myid:] - INFO [main:Environment@100] - Client environment:os.version=3.10.0-514.el7.x86_64 2018-05-24 13:42:35,483 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root 2018-05-24 13:42:35,483 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root 2018-05-24 13:42:35,483 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/mirana/software/zookeeper/zk03/bin 2018-05-24 13:42:35,485 [myid:] - INFO [main:ZooKeeper@441] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@22d8cfe0 2018-05-24 13:42:35,537 [myid:] - INFO [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1028] - Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error) Welcome to ZooKeeper! JLine support is enabled 2018-05-24 13:42:35,725 [myid:] - INFO [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@878] - Socket connection established to 127.0.0.1/127.0.0.1:2181, initiating session 2018-05-24 13:42:35,780 [myid:] - INFO [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1302] - Session establishment complete on server 127.0.0.1/127.0.0.1:2181, sessionid = 0x100004150da0004, negotiated timeout = 30000 WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: 127.0.0.1:2181(CONNECTED) 0]
2、添加并查看节点数据
2.1添加根节点"node_1",节点数据为"data1"
[zk: 127.0.0.1:2181(CONNECTED) 1] ls / [zookeeper] [zk: 127.0.0.1:2181(CONNECTED) 2] create /node_1 data1 Created /node_1 [zk: 127.0.0.1:2181(CONNECTED) 3] ls / [zookeeper, node_1] [zk: 127.0.0.1:2181(CONNECTED) 4] get /node_1 data1 cZxid = 0x300000017 ctime = Thu May 24 13:44:32 CST 2018 mZxid = 0x300000017 mtime = Thu May 24 13:44:32 CST 2018 pZxid = 0x300000017 cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 5 numChildren = 0 [zk: 127.0.0.1:2181(CONNECTED) 5]
2.2 添加连续的节点,保证znode路径唯一
[zk: 127.0.0.1:2181(CONNECTED) 7] create -s /node_1/node1.1 /data1.1.1 Created /node_1/node1.10000000001 [zk: 127.0.0.1:2181(CONNECTED) 8] create -s /node_1/node1.1 /data1.1.2 Created /node_1/node1.10000000002 [zk: 127.0.0.1:2181(CONNECTED) 9] create -s /node_1/node1.1 /data1.1.3 Created /node_1/node1.10000000003 [zk: 127.0.0.1:2181(CONNECTED) 10] create -s /node_1/node1.1 /data1.1.4 Created /node_1/node1.10000000004 [zk: 127.0.0.1:2181(CONNECTED) 11] create -s /node_1/node1.1 /data1.1.5 Created /node_1/node1.10000000005 [zk: 127.0.0.1:2181(CONNECTED) 1] ls /node_1 [node1.10000000001, node1.10000000003, node1.10000000002, node1.10000000005, node1.10000000004] [zk: 127.0.0.1:2181(CONNECTED) 2] get /node_1/node1.10000000001 /data1.1.1 cZxid = 0x30000001a ctime = Thu May 24 13:48:03 CST 2018 mZxid = 0x30000001a mtime = Thu May 24 13:48:03 CST 2018 pZxid = 0x30000001a cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 10 numChildren = 0 [zk: 127.0.0.1:2181(CONNECTED) 3] get /node_1/node1.10000000002 /data1.1.2 cZxid = 0x30000001b ctime = Thu May 24 13:48:08 CST 2018 mZxid = 0x30000001b mtime = Thu May 24 13:48:08 CST 2018 pZxid = 0x30000001b cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 10 numChildren = 0 [zk: 127.0.0.1:2181(CONNECTED) 4] get /node_1/node1.10000000003 /data1.1.3 cZxid = 0x30000001c ctime = Thu May 24 13:48:09 CST 2018 mZxid = 0x30000001c mtime = Thu May 24 13:48:09 CST 2018 pZxid = 0x30000001c cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 10 numChildren = 0 [zk: 127.0.0.1:2181(CONNECTED) 5] get /node_1/node1.10000000004 /data1.1.4 cZxid = 0x30000001d ctime = Thu May 24 13:48:10 CST 2018 mZxid = 0x30000001d mtime = Thu May 24 13:48:10 CST 2018 pZxid = 0x30000001d cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 10 numChildren = 0 [zk: 127.0.0.1:2181(CONNECTED) 6] get /node_1/node1.10000000005 /data1.1.5 cZxid = 0x30000001e ctime = Thu May 24 13:48:12 CST 2018 mZxid = 0x30000001e mtime = Thu May 24 13:48:12 CST 2018 pZxid = 0x30000001e cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 10 numChildren = 0
[zk: 127.0.0.1:2181(CONNECTED) 7] get /node_1/node1.1
Node does not exist: /node_1/node1.1
2.3 添加临时节点node1.2,重新连接后将无法获取对应的节点及其数据
[zk: 127.0.0.1:2181(CONNECTED) 9] create -e /node_1/node1.2 data1.2 Created /node_1/node1.2 [zk: 127.0.0.1:2181(CONNECTED) 11] create -e /node_1/node1.3 data1.3 Created /node_1/node1.3 [zk: 127.0.0.1:2181(CONNECTED) 12] create -e /node_1/node1.4 data1.4 Created /node_1/node1.4 [zk: 127.0.0.1:2181(CONNECTED) 13] ls /node_1 [node1.4, node1.3, node1.2, node1.10000000001, node1.10000000003, node1.10000000002, node1.10000000005, node1.10000000004] [zk: 127.0.0.1:2181(CONNECTED) 14] quit Quitting... 2018-05-24 13:56:05,317 [myid:] - INFO [main:ZooKeeper@687] - Session: 0x100004150da0005 closed 2018-05-24 13:56:05,324 [myid:] - INFO [main-EventThread:ClientCnxn$EventThread@521] - EventThread shut down for session: 0x100004150da0005 [root@localhost bin]# ./zkCli.sh -server 127.0.0.1:2181 Connecting to 127.0.0.1:2181 2018-05-24 13:56:07,920 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.12-e5259e437540f349646870ea94dc2658c4e44b3b, built on 03/27/2018 03:55 GMT 2018-05-24 13:56:07,926 [myid:] - INFO [main:Environment@100] - Client environment:host.name=localhost 2018-05-24 13:56:07,926 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_172 2018-05-24 13:56:07,932 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation 2018-05-24 13:56:07,947 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/mirana/software/jdk1.8/jre 2018-05-24 13:56:07,947 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/mirana/software/zookeeper/zk03/bin/../build/classes:/mirana/software/zookeeper/zk03/bin/../build/lib/*.jar:/mirana/software/zookeeper/zk03/bin/../lib/slf4j-log4j12-1.7.25.jar:/mirana/software/zookeeper/zk03/bin/../lib/slf4j-api-1.7.25.jar:/mirana/software/zookeeper/zk03/bin/../lib/netty-3.10.6.Final.jar:/mirana/software/zookeeper/zk03/bin/../lib/log4j-1.2.17.jar:/mirana/software/zookeeper/zk03/bin/../lib/jline-0.9.94.jar:/mirana/software/zookeeper/zk03/bin/../lib/audience-annotations-0.5.0.jar:/mirana/software/zookeeper/zk03/bin/../zookeeper-3.4.12.jar:/mirana/software/zookeeper/zk03/bin/../src/java/lib/*.jar:/mirana/software/zookeeper/zk03/bin/../conf:/mirana/software/jdk1.8/jre/lib/rt.jar:/mirana/software/jdk1.8/jre/lib/ext 2018-05-24 13:56:07,948 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 2018-05-24 13:56:07,948 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp 2018-05-24 13:56:07,948 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=<NA> 2018-05-24 13:56:07,948 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux 2018-05-24 13:56:07,948 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64 2018-05-24 13:56:07,948 [myid:] - INFO [main:Environment@100] - Client environment:os.version=3.10.0-514.el7.x86_64 2018-05-24 13:56:07,948 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root 2018-05-24 13:56:07,949 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root 2018-05-24 13:56:07,949 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/mirana/software/zookeeper/zk03/bin 2018-05-24 13:56:07,955 [myid:] - INFO [main:ZooKeeper@441] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@22d8cfe0 2018-05-24 13:56:08,002 [myid:] - INFO [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1028] - Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error) Welcome to ZooKeeper! JLine support is enabled 2018-05-24 13:56:08,221 [myid:] - INFO [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@878] - Socket connection established to 127.0.0.1/127.0.0.1:2181, initiating session 2018-05-24 13:56:08,254 [myid:] - INFO [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1302] - Session establishment complete on server 127.0.0.1/127.0.0.1:2181, sessionid = 0x100004150da0006, negotiated timeout = 30000 WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: 127.0.0.1:2181(CONNECTED) 0] ls /node_1/node1.1000000000 node1.10000000001 node1.10000000003 node1.10000000002 node1.10000000005 node1.10000000004 [zk: 127.0.0.1:2181(CONNECTED) 0] ls /node_1/ Command failed: java.lang.IllegalArgumentException: Path must not end with / character [zk: 127.0.0.1:2181(CONNECTED) 1] ls /node_1 [node1.10000000001, node1.10000000003, node1.10000000002, node1.10000000005, node1.10000000004] [zk: 127.0.0.1:2181(CONNECTED) 2] get /node_1/node1.2 Node does not exist: /node_1/node1.2 [zk: 127.0.0.1:2181(CONNECTED) 3]
3、修改节点数据
[zk: 127.0.0.1:2181(CONNECTED) 4] create /node_2/node2.1 data2.1 Created /node_2/node2.1 [zk: 127.0.0.1:2181(CONNECTED) 0] ls /node_2 [node2.1] [zk: 127.0.0.1:2181(CONNECTED) 1] get /node_2/node2.1 data2.1 cZxid = 0x300000027 ctime = Thu May 24 14:02:58 CST 2018 mZxid = 0x300000027 mtime = Thu May 24 14:02:58 CST 2018 pZxid = 0x300000027 cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 7 numChildren = 0 [zk: 127.0.0.1:2181(CONNECTED) 2] set /node_2/node2.1 data2.1.1 cZxid = 0x300000027 ctime = Thu May 24 14:02:58 CST 2018 mZxid = 0x300000029 mtime = Thu May 24 14:03:28 CST 2018 pZxid = 0x300000027 cversion = 0 dataVersion = 1 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 9 numChildren = 0 [zk: 127.0.0.1:2181(CONNECTED) 3] get /node_2/node2.1 data2.1.1 cZxid = 0x300000027 ctime = Thu May 24 14:02:58 CST 2018 mZxid = 0x300000029 mtime = Thu May 24 14:03:28 CST 2018 pZxid = 0x300000027 cversion = 0 dataVersion = 1 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 9 numChildren = 0 [zk: 127.0.0.1:2181(CONNECTED) 4]
4、删除节点
4.1 若当前节点没有子节点,执行delete /path
[zk: 127.0.0.1:2181(CONNECTED) 4] delete /node_2/node2.1
4.2 若当前节点有子节点,执行rmr /path
[zk: 127.0.0.1:2181(CONNECTED) 5] rmr /node_1 [zk: 127.0.0.1:2181(CONNECTED) 6] rmr /node_2 [zk: 127.0.0.1:2181(CONNECTED) 7] ls / [zookeeper]
5、zookeeper集群下的数据同步
# 连接到zk01的2181 [root@localhost bin]# ./zkCli.sh -server 127.0.0.1:2181 Connecting to 127.0.0.1:2181 2018-05-24 14:16:24,693 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.12-e5259e437540f349646870ea94dc2658c4e44b3b, built on 03/27/2018 03:55 GMT 2018-05-24 14:16:24,698 [myid:] - INFO [main:Environment@100] - Client environment:host.name=localhost 2018-05-24 14:16:24,698 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_172 2018-05-24 14:16:24,712 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation 2018-05-24 14:16:24,713 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/mirana/software/jdk1.8/jre 2018-05-24 14:16:24,714 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/mirana/software/zookeeper/zk03/bin/../build/classes:/mirana/software/zookeeper/zk03/bin/../build/lib/*.jar:/mirana/software/zookeeper/zk03/bin/../lib/slf4j-log4j12-1.7.25.jar:/mirana/software/zookeeper/zk03/bin/../lib/slf4j-api-1.7.25.jar:/mirana/software/zookeeper/zk03/bin/../lib/netty-3.10.6.Final.jar:/mirana/software/zookeeper/zk03/bin/../lib/log4j-1.2.17.jar:/mirana/software/zookeeper/zk03/bin/../lib/jline-0.9.94.jar:/mirana/software/zookeeper/zk03/bin/../lib/audience-annotations-0.5.0.jar:/mirana/software/zookeeper/zk03/bin/../zookeeper-3.4.12.jar:/mirana/software/zookeeper/zk03/bin/../src/java/lib/*.jar:/mirana/software/zookeeper/zk03/bin/../conf:/mirana/software/jdk1.8/jre/lib/rt.jar:/mirana/software/jdk1.8/jre/lib/ext 2018-05-24 14:16:24,714 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 2018-05-24 14:16:24,714 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp 2018-05-24 14:16:24,715 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=<NA> 2018-05-24 14:16:24,715 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux 2018-05-24 14:16:24,715 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64 2018-05-24 14:16:24,715 [myid:] - INFO [main:Environment@100] - Client environment:os.version=3.10.0-514.el7.x86_64 2018-05-24 14:16:24,715 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root 2018-05-24 14:16:24,715 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root 2018-05-24 14:16:24,715 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/mirana/software/zookeeper/zk03/bin 2018-05-24 14:16:24,733 [myid:] - INFO [main:ZooKeeper@441] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@22d8cfe0 2018-05-24 14:16:24,777 [myid:] - INFO [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1028] - Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error) Welcome to ZooKeeper! JLine support is enabled 2018-05-24 14:16:25,001 [myid:] - INFO [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@878] - Socket connection established to 127.0.0.1/127.0.0.1:2181, initiating session 2018-05-24 14:16:25,040 [myid:] - INFO [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1302] - Session establishment complete on server 127.0.0.1/127.0.0.1:2181, sessionid = 0x100004150da0009, negotiated timeout = 30000 WATCHER:: WatchedEvent state:SyncConnected type:None path:null # 查看根节点,并创建node100的节点,数据为data100 [zk: 127.0.0.1:2181(CONNECTED) 0] ls [zk: 127.0.0.1:2181(CONNECTED) 1] ls / [zookeeper] [zk: 127.0.0.1:2181(CONNECTED) 2] create /node100 data100 Created /node100 [zk: 127.0.0.1:2181(CONNECTED) 3] get /node100 data100 cZxid = 0x30000003d ctime = Thu May 24 14:16:44 CST 2018 mZxid = 0x30000003d mtime = Thu May 24 14:16:44 CST 2018 pZxid = 0x30000003d cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 7 numChildren = 0 # 退出zk01的2181端口 [zk: 127.0.0.1:2181(CONNECTED) 4] quit # 连接zk03的2183端口 [root@localhost bin]# ./zkCli.sh -server 127.0.0.1:2183 Connecting to 127.0.0.1:2183 2018-05-24 14:16:57,791 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.12-e5259e437540f349646870ea94dc2658c4e44b3b, built on 03/27/2018 03:55 GMT 2018-05-24 14:16:57,798 [myid:] - INFO [main:Environment@100] - Client environment:host.name=localhost 2018-05-24 14:16:57,798 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_172 2018-05-24 14:16:57,810 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation 2018-05-24 14:16:57,810 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/mirana/software/jdk1.8/jre 2018-05-24 14:16:57,810 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/mirana/software/zookeeper/zk03/bin/../build/classes:/mirana/software/zookeeper/zk03/bin/../build/lib/*.jar:/mirana/software/zookeeper/zk03/bin/../lib/slf4j-log4j12-1.7.25.jar:/mirana/software/zookeeper/zk03/bin/../lib/slf4j-api-1.7.25.jar:/mirana/software/zookeeper/zk03/bin/../lib/netty-3.10.6.Final.jar:/mirana/software/zookeeper/zk03/bin/../lib/log4j-1.2.17.jar:/mirana/software/zookeeper/zk03/bin/../lib/jline-0.9.94.jar:/mirana/software/zookeeper/zk03/bin/../lib/audience-annotations-0.5.0.jar:/mirana/software/zookeeper/zk03/bin/../zookeeper-3.4.12.jar:/mirana/software/zookeeper/zk03/bin/../src/java/lib/*.jar:/mirana/software/zookeeper/zk03/bin/../conf:/mirana/software/jdk1.8/jre/lib/rt.jar:/mirana/software/jdk1.8/jre/lib/ext 2018-05-24 14:16:57,810 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 2018-05-24 14:16:57,810 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp 2018-05-24 14:16:57,810 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=<NA> 2018-05-24 14:16:57,811 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux 2018-05-24 14:16:57,811 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64 2018-05-24 14:16:57,811 [myid:] - INFO [main:Environment@100] - Client environment:os.version=3.10.0-514.el7.x86_64 2018-05-24 14:16:57,811 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root 2018-05-24 14:16:57,811 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root 2018-05-24 14:16:57,811 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/mirana/software/zookeeper/zk03/bin 2018-05-24 14:16:57,813 [myid:] - INFO [main:ZooKeeper@441] - Initiating client connection, connectString=127.0.0.1:2183 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@22d8cfe0 2018-05-24 14:16:57,870 [myid:] - INFO [main-SendThread(127.0.0.1:2183):ClientCnxn$SendThread@1028] - Opening socket connection to server 127.0.0.1/127.0.0.1:2183. Will not attempt to authenticate using SASL (unknown error) Welcome to ZooKeeper! JLine support is enabled 2018-05-24 14:16:58,074 [myid:] - INFO [main-SendThread(127.0.0.1:2183):ClientCnxn$SendThread@878] - Socket connection established to 127.0.0.1/127.0.0.1:2183, initiating session 2018-05-24 14:16:58,106 [myid:] - INFO [main-SendThread(127.0.0.1:2183):ClientCnxn$SendThread@1302] - Session establishment complete on server 127.0.0.1/127.0.0.1:2183, sessionid = 0x3000041608d0001, negotiated timeout = 30000 WATCHER:: WatchedEvent state:SyncConnected type:None path:null # 查看在zk01创建的节点数据/node100 [zk: 127.0.0.1:2183(CONNECTED) 0] get /node100 data100 cZxid = 0x30000003d ctime = Thu May 24 14:16:44 CST 2018 mZxid = 0x30000003d mtime = Thu May 24 14:16:44 CST 2018 pZxid = 0x30000003d cversion = 0 dataVersion = 0 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 7 numChildren = 0 # 修改/node100的数据为data100_100 [zk: 127.0.0.1:2183(CONNECTED) 1] set /node100 data100_100 cZxid = 0x30000003d ctime = Thu May 24 14:16:44 CST 2018 mZxid = 0x30000003f mtime = Thu May 24 14:17:12 CST 2018 pZxid = 0x30000003d cversion = 0 dataVersion = 1 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 11 numChildren = 0 [zk: 127.0.0.1:2183(CONNECTED) 2] get /node100 data100_100 cZxid = 0x30000003d ctime = Thu May 24 14:16:44 CST 2018 mZxid = 0x30000003f mtime = Thu May 24 14:17:12 CST 2018 pZxid = 0x30000003d cversion = 0 dataVersion = 1 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 11 numChildren = 0 [zk: 127.0.0.1:2183(CONNECTED) 3] quit Quitting... 2018-05-24 14:17:18,078 [myid:] - INFO [main:ZooKeeper@687] - Session: 0x3000041608d0001 closed 2018-05-24 14:17:18,085 [myid:] - INFO [main-EventThread:ClientCnxn$EventThread@521] - EventThread shut down for session: 0x3000041608d0001 # 在zk01下查看上次在zk03下修改后的/node100的数据 [root@localhost bin]# ./zkCli.sh -server 127.0.0.1:2181 Connecting to 127.0.0.1:2181 2018-05-24 14:17:20,160 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.12-e5259e437540f349646870ea94dc2658c4e44b3b, built on 03/27/2018 03:55 GMT 2018-05-24 14:17:20,165 [myid:] - INFO [main:Environment@100] - Client environment:host.name=localhost 2018-05-24 14:17:20,166 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_172 2018-05-24 14:17:20,171 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation 2018-05-24 14:17:20,171 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/mirana/software/jdk1.8/jre 2018-05-24 14:17:20,172 [myid:] - INFO [main:Environment@100] - Client environment:java.class.path=/mirana/software/zookeeper/zk03/bin/../build/classes:/mirana/software/zookeeper/zk03/bin/../build/lib/*.jar:/mirana/software/zookeeper/zk03/bin/../lib/slf4j-log4j12-1.7.25.jar:/mirana/software/zookeeper/zk03/bin/../lib/slf4j-api-1.7.25.jar:/mirana/software/zookeeper/zk03/bin/../lib/netty-3.10.6.Final.jar:/mirana/software/zookeeper/zk03/bin/../lib/log4j-1.2.17.jar:/mirana/software/zookeeper/zk03/bin/../lib/jline-0.9.94.jar:/mirana/software/zookeeper/zk03/bin/../lib/audience-annotations-0.5.0.jar:/mirana/software/zookeeper/zk03/bin/../zookeeper-3.4.12.jar:/mirana/software/zookeeper/zk03/bin/../src/java/lib/*.jar:/mirana/software/zookeeper/zk03/bin/../conf:/mirana/software/jdk1.8/jre/lib/rt.jar:/mirana/software/jdk1.8/jre/lib/ext 2018-05-24 14:17:20,173 [myid:] - INFO [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib 2018-05-24 14:17:20,174 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp 2018-05-24 14:17:20,174 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=<NA> 2018-05-24 14:17:20,174 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux 2018-05-24 14:17:20,174 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64 2018-05-24 14:17:20,174 [myid:] - INFO [main:Environment@100] - Client environment:os.version=3.10.0-514.el7.x86_64 2018-05-24 14:17:20,174 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root 2018-05-24 14:17:20,174 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root 2018-05-24 14:17:20,175 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/mirana/software/zookeeper/zk03/bin 2018-05-24 14:17:20,177 [myid:] - INFO [main:ZooKeeper@441] - Initiating client connection, connectString=127.0.0.1:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@22d8cfe0 2018-05-24 14:17:20,219 [myid:] - INFO [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1028] - Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error) Welcome to ZooKeeper! JLine support is enabled 2018-05-24 14:17:20,415 [myid:] - INFO [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@878] - Socket connection established to 127.0.0.1/127.0.0.1:2181, initiating session 2018-05-24 14:17:20,460 [myid:] - INFO [main-SendThread(127.0.0.1:2181):ClientCnxn$SendThread@1302] - Session establishment complete on server 127.0.0.1/127.0.0.1:2181, sessionid = 0x100004150da000a, negotiated timeout = 30000 WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: 127.0.0.1:2181(CONNECTED) 0] get /node100 data100_100 cZxid = 0x30000003d ctime = Thu May 24 14:16:44 CST 2018 mZxid = 0x30000003f mtime = Thu May 24 14:17:12 CST 2018 pZxid = 0x30000003d cversion = 0 dataVersion = 1 aclVersion = 0 ephemeralOwner = 0x0 dataLength = 11 numChildren = 0 [zk: 127.0.0.1:2181(CONNECTED) 1]