ZooKeeper 基础8

2022-03-25 14:23:41 浏览数 (1)

close

主动断开当前连接

代码语言:javascript复制
[zk: localhost:2181(CONNECTED) 14] ls /
[test, zookeeper]
[zk: localhost:2181(CONNECTED) 15] close 
2015-12-03 15:50:51,211 [myid:] - INFO  [main:ZooKeeper@684] - Session: 0x151665fb7430003 closed
[zk: localhost:2181(CLOSED) 16] 2015-12-03 15:50:51,211 [myid:] - INFO  [main-EventThread:ClientCnxn$EventThread@512] - EventThread shut down

[zk: localhost:2181(CLOSED) 16] 
[zk: localhost:2181(CLOSED) 16] ls /
Not connected
[zk: localhost:2181(CLOSED) 17] 

connect

连接服务

代码语言:javascript复制
[zk: localhost:2181(CLOSED) 16] ls /
Not connected
[zk: localhost:2181(CLOSED) 17] connect localhost:2181
2015-12-03 16:40:11,981 [myid:] - INFO  [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@7a450ea8
2015-12-03 16:40:11,988 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@975] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)
[zk: localhost:2181(CONNECTING) 18] 2015-12-03 16:40:12,014 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@852] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session
2015-12-03 16:40:12,028 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1235] - Session establishment complete on server localhost/0:0:0:0:0:0:0:1:2181, sessionid = 0x151665fb7430004, negotiated timeout = 30000

WATCHER::

WatchedEvent state:SyncConnected type:None path:null

[zk: localhost:2181(CONNECTED) 18] ls /
[test, zookeeper]
[zk: localhost:2181(CONNECTED) 19] 

quit

退出

代码语言:javascript复制
[zk: localhost:2181(CONNECTED) 80] quit
Quitting...
2015-12-03 15:48:27,285 [myid:] - INFO  [main:ZooKeeper@684] - Session: 0x151665fb7430001 closed
2015-12-03 15:48:27,294 [myid:] - INFO  [main-EventThread:ClientCnxn$EventThread@512] - EventThread shut down
[root@h101 bin]# 

0 人点赞