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:(CONNECTED) 7] get /node_1/node1.
Node does not exist: /node_1/node1.
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]
zookeeper 数据节点的增删改查的更多相关文章
- ZooKeeper客户端 zkCli.sh 节点的增删改查
zkCli.sh 在 bin 目录下的 zkCli.sh 就是ZooKeeper客户端 ./zkCli.sh -timeout 5000 -server 127.0.0.1:2181 客户端与 ...
- Zookeeper入门(六)之zkCli.sh对节点的增删改查
参考地址为:https://www.cnblogs.com/sherrykid/p/5813148.html 1.连接 在 bin 目录下的 zkCli.sh 就是ZooKeeper客户端 ./z ...
- zookeeper curator客户端之增删改查
zookeeper curator客户端之增删改查 zookeeper安装:https://www.cnblogs.com/zwcry/p/10272506.html curator客户端是Apach ...
- java springboot整合zookeeper入门教程(增删改查)
java springboot整合zookeeper增删改查入门教程 zookeeper的安装与集群搭建参考:https://www.cnblogs.com/zwcry/p/10272506.html ...
- AngularJS中使用$http对MongoLab数据表进行增删改查
本篇体验使用AngularJS中的$http对MongoLab数据表进行增删改查. 主页面: <button ng-click="loadCourse()">Load ...
- HTML DOM(二):节点的增删改查
上一篇讲述了DOM的基本知识,从其得知,在DOM眼中,HTML的每个成分都可以看作是节点(文档节点.元素节点.文本节点.属性节点.注释节点,其中,属性节点是属于元素节点),本篇的内容就是通过DOM对这 ...
- HTML DOM节点的增删改查
上篇博客中,我们已经初步接触了DOM基础,可是我们学习是为了可以更好地应用,今天我们就来看看DOM节点的增删改查. 无论在哪里,我们想要操作一个东西,总是应该先去获得它.那么我们怎么获得呢? HTML ...
- Mysql数据表的增删改查
---恢复内容开始--- Mysql数据表的增删改查 1.创建表 语法:CREATE TABLE 表名(字段1,字段2,字段3.......) CREATE TABLE `users` ( `us ...
- jQuery EasyUI/TopJUI实现数据表格的增删改查功能(不写js,纯HTML实现!!!)
jQuery EasyUI/TopJUI实现数据表格的增删改查功能(不写js,纯HTML实现!!!) 废话不多说,直接贴上代码 <table id="configEdatagrid&q ...
随机推荐
- CodeForces 427B Prison Transfer (滑动窗口)
题意:给定 n, t, c 和 n 个数,问你在这 n 个数中有多少连续的 c 个数,并且这个 c 个数不大于 t. 析:很简单么,是滑动窗口,从第一个开始遍历,如果找到 c 个数,那么让区间前端点加 ...
- VC:GetWindowRect、GetClientRect、ScreenToClient与ClientToScreen
GetWindowRect是取得窗口在屏幕坐标系下的RECT坐标(包括客户区和非客户区),这样可以得到窗口的大小和相对屏幕左上角(0,0)的位置. GetClientRect取得窗口客户区(不包括非客 ...
- delphi Table切换控件顺序问题
delphi Table切换控件顺序问题 Tagorder的值就是确定Table键切换顺序的 以上做法只能解决同一类型的多个控件(如Edit1,edit2....)显示顺序问题 假如有不同类型的控件如 ...
- Windows下Mongodb安装及配置(转载)
转载(https://blog.csdn.net/liang377122210/article/details/79062681) MongoDB的安装很简单,设置好安装路径后,一直Next直到安装结 ...
- [SIP01]SIP Header Fields里面各字段用途
INVITE sip:bob@biloxi.com SIP/2.0 Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds Max-Forw ...
- ASP.NET MVC 如何使用自定义过滤器(筛选器)
继承*****Attribute(筛选器三种具体类)-->重写方法-->标记在控制器 或者 方法上面 或者 在FilterConfig中Add [类名(类属性 = 值)]还有[AllowA ...
- STM32 IAP+Ymodem功能实现(参考官方代码)
IAP:在线升级代码 ,通俗的讲就是通过USART,IIC,或者SPI,USB等等,方式,在程序中升级程序,一般用在远程升级,或者是在PCB板子都安装到模具之后还需要升级代码,这样我们就需要,通过IA ...
- Entity Framework异步查询和保存
EF6开始提供了通过async和await关键字实现异步查询和保存的支持(.net 4.5及更高版本).虽然不是所有的操作都能从异步中获益,但是耗时的操作.网络或IO密集型任务中,使用异步可以提升客户 ...
- Mysql 学习笔记09
---Mysql 的主从复制 replication 1 主从复制原理 至少有2台服务器,一台主服务器,一台从服务器,主服务器的所有改动,如 insert update delete 操作,都会同步 ...
- Python——使用matplotlib绘制柱状图
Python——使用matplotlib绘制柱状图 1.基本柱状图 首先要安装matplotlib(http://matplotlib.org/api/pyplot_api.htm ...