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 ...
随机推荐
- soapUI的bug切换版本解决
目录 文章背景 目录 运行环境及出现的问题 问题解决 说明 参考文章 版本记录 文章背景 为公司编写了一个webservice,本地测试时候是没有问题的,发布到现场之后,访问出现异常,通过切换soap ...
- 编写高质量代码改善C#程序的157个建议——建议147:重构多个相关属性为一个类
建议147:重构多个相关属性为一个类 若存在多个相关属性,就应该考虑是否将其重构为一个类.查看如下类: class Person { public string Address { get; set; ...
- spring mvc---controller返回值
1.ModelAndView 类似servlet,之前例子在用 addObject setViewName 2.String a.表示返回逻辑视图名 spring mvc的视图解析器中设置.(在web ...
- google earth 中的飞行模拟器的键盘控制
- Linux 判断进程是否已经运行的程序
bool ServerProcess::isAlreadyRunning() { #ifndef __linux__ WarningLog(<<"can't check if p ...
- Java中的多态方法
public class Main { public void test(Object o) { System.out.println("Object"); } public vo ...
- 学习做爬虫-vs2017
最近新装了vs2017,安装过程发生了很大的变化,操作变的更加容易了. 下载vs安装程序进行安装.更新界面如图所示,我选择了安装免费个人版(这个是已安装的更新界面,和安装界面差不多) 如图所示,这样的 ...
- C#高级特性:动态绑定
C#高级特性:动态绑定 动态绑定 动态绑定将类型绑定(类型解析.成员和操作过程)从编译时推迟到了运行时.在编译时,如果程序员知道某个特定函数.成员的存在而编译器不知道,那么这种操作是非常有用的,这种情 ...
- Zeal - 开源离线开发文档浏览器
https://zealdocs.org/ win10上暂时安装版会crash,请用portalable的解压版
- sharepoint用户信息同步出错
首先使用工具定位问题,然后权限不够授予权限 C:\Program Files\Microsoft Office Servers\15.0\Synchronization Service\UIShell