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 数据节点的增删改查的更多相关文章

  1. ZooKeeper客户端 zkCli.sh 节点的增删改查

    zkCli.sh 在 bin 目录下的  zkCli.sh  就是ZooKeeper客户端 ./zkCli.sh -timeout 5000  -server 127.0.0.1:2181  客户端与 ...

  2. Zookeeper入门(六)之zkCli.sh对节点的增删改查

    参考地址为:https://www.cnblogs.com/sherrykid/p/5813148.html 1.连接 在 bin 目录下的  zkCli.sh  就是ZooKeeper客户端 ./z ...

  3. zookeeper curator客户端之增删改查

    zookeeper curator客户端之增删改查 zookeeper安装:https://www.cnblogs.com/zwcry/p/10272506.html curator客户端是Apach ...

  4. java springboot整合zookeeper入门教程(增删改查)

    java springboot整合zookeeper增删改查入门教程 zookeeper的安装与集群搭建参考:https://www.cnblogs.com/zwcry/p/10272506.html ...

  5. AngularJS中使用$http对MongoLab数据表进行增删改查

    本篇体验使用AngularJS中的$http对MongoLab数据表进行增删改查. 主页面: <button ng-click="loadCourse()">Load ...

  6. HTML DOM(二):节点的增删改查

    上一篇讲述了DOM的基本知识,从其得知,在DOM眼中,HTML的每个成分都可以看作是节点(文档节点.元素节点.文本节点.属性节点.注释节点,其中,属性节点是属于元素节点),本篇的内容就是通过DOM对这 ...

  7. HTML DOM节点的增删改查

    上篇博客中,我们已经初步接触了DOM基础,可是我们学习是为了可以更好地应用,今天我们就来看看DOM节点的增删改查. 无论在哪里,我们想要操作一个东西,总是应该先去获得它.那么我们怎么获得呢? HTML ...

  8. Mysql数据表的增删改查

    ---恢复内容开始--- Mysql数据表的增删改查 1.创建表   语法:CREATE TABLE 表名(字段1,字段2,字段3.......) CREATE TABLE `users` ( `us ...

  9. jQuery EasyUI/TopJUI实现数据表格的增删改查功能(不写js,纯HTML实现!!!)

    jQuery EasyUI/TopJUI实现数据表格的增删改查功能(不写js,纯HTML实现!!!) 废话不多说,直接贴上代码 <table id="configEdatagrid&q ...

随机推荐

  1. scrapy爬虫事件以及数据保存为txt,json,mysql

    今天要爬取的网页是虎嗅网 我们将完成如下几个步骤: 创建一个新的Scrapy工程 定义你所需要要抽取的Item对象 编写一个spider来爬取某个网站并提取出所有的Item对象 编写一个Item Pi ...

  2. zuluCryt cli howto

    1.解锁卷的命令. zuluCrypt-cli -o -d /dev/sdc1 -m blabla -e ro -f /home/keyFile zuluCrypt-cli -o -d /dev/sd ...

  3. win7 iis7 ftp配置

    1.安装ftp服务器 开始菜单找到控制面板>在左侧找到打开或关闭windows功能点击 弹出如下对话框, 在弹出的对话框中找到Internet信息服务,如下 然后如上图所示,选中ftp服务器复选 ...

  4. .net 有参属性 index (索引)

    public class IndexTempte { public ArrayList nameList = new ArrayList(); public string this[int index ...

  5. EF修改model自动更新数据库

    最近用MVC+EF学习时遇到修改model后而数据库没更新报错,就在网上找关于数据迁移自动更新数据库的,折腾了大半天终于弄了出来 第一步:在程序包管理器控制台里: Enable-Migrations ...

  6. ORM概述及常用ORM框架

    一.ORM ORM(Object-relational mapping),即对象关系映射,是一种为了解决面向对象与关系数据库存在的互不匹配的现象的技术.也就是说,ORM是通过使用描述对象和数据库之间映 ...

  7. 工作流2013 assign to问题

    根据您的确认, 该问题已经通过我们所提供的方案进行修改后测试通过, 问题解决. 以下为该问题的产生原因: SharePoint 2013使用的默认认证机制与2007不一样,  2007使用的是Wind ...

  8. Luckily general gradient for spherical harmonics is defined

    http://web4.cs.ucl.ac.uk/staff/j.kautz/publications/gradientSH_RS04.pdf

  9. 适用于Java的嵌入式脚本语言

    此文已由作者赵昕授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. fakescript 轻量级嵌入式脚本语言 https://github.com/esrrhs/fakescr ...

  10. 一文读懂加固apk的开发者是怎么想的

    有人说加固会明显拖慢启动速度,同时造成运行卡顿,严重降低用户体验,而且加固是完全可以脱壳的,只需要pc配合进行断点调试就能抓到解密后的dex文件,加固并没有所说的那么安全. 但是为什么还有一大批开发者 ...