Zookeeper 从入门到入土⑤:四字命令(Four Letter Words)

安装 nc: yum install nc
命令格式: echo [commond] | nc [ip] [port]
stat: 查看 zk 的状态信息

1
2
3
4
5
6
7
8
9
10
11
12
[root@izbp101vzs716yznuegsljz bin]# echo stat | nc localhost 2181
Zookeeper version: 3.4.9-1757313, built on 08/23/2016 06:50 GMTClients:
/127.0.0.1:55394 [0] (queued-0, recved=1, sent=0)

Latency min/avg/max: 0/0/0
Received: 2
Sent: 1
Connections: 1
Outatanding: 0
Zxid: 0xed
Mode: standalone
Node count: 29

conf: 查看服务器配置

1
2
3
4
5
6
7
8
9
[root@izbp101vzs716yznuegsljz bin]# echo conf | nc localhost 2181
clientFort=2181
dataDir=/uar/local/zookeeper-3.4.9/dataDir/version-2
dataLogDir=/usr/local/zookeeper-3.4.9/dataLoaDir/version-2
tickTime=2000
maxClientCnxns=60
minSessionTimeout=4000
maxSessionTimeout=40000
serverId=0

cons: 显示连接到服务器的客户端信息

1
2
3
[root@izbp101vzs716yznuegsljz bin]# echo cons | nc localhost 2181
/127.0.0.1:55442[1](queued-0,recved=1,sent=1,sid=0x16b1af459260001,lop=SESS,est=1559532063700,to=30000,lcxid=0x0,lzxid=0x0,lresp=1559532063718,llat=5,minlat=0,avglat=5,maxlat=5)
/127.0.0.1:55444[0](queued=0,recved=1,sent=0)

envi: 环境变量

1
2
3
4
5
6
7
8
[root@izbp101vzs716yznuegsljz bin]# echo envi | nc localhost 2181
Environment:
zookeeper.version=3.4.9-1757313, built on 08/23/2016 06:50 GMT
host,name=izbp101vzs716yznuegsliz
java.version=1.8.0_201
java.vendor=Oracle Corporation
java.home=/usr/jdk/jdk1.8.0_ 201/jre
...

mntr: 监控 zk 健康信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@izbp101vzs716yznuegsljz bin]# echo mntr | nc localhost 2181
zk_version 3.4.9-1757313, built on o8/23/2016 06:50 GMT
zk_avg_latency 0
zk_max_latency 25
zk_min_latency 0
zk_packets_received 78
zk_packets_sent 77
zk_num_alive_connections
zk_outstanding_requests 0
zk_server_state standalone
zk_znode_count 29
zk_watch_count 0
zk_ephemerals_count 0
zk_approximate_data_size 553
zk_open_file_descriptor_count 27
zk_max_file_descriptor_count 65535

wchs: 显示 watch 的信息

1
2
3
[root@izbp101vzs716yznuegsljz bin]# echo wchs | nc localhost 2181
1 connections watching 1 paths
Total watches:1

wchc: watch 的 session 与 watch

1
2
3
[root@izbp101vzs716yznuegsljz bin]# echo wchc | nc localhost 2181
0x16b1af459260001
/zookeeper

wchp: watch 的 path 与 watch 信息

1
2
3
[root@izbp101vzs716yznuegsljz bin]# echo wchp | nc localhost 2181
/zookeeper
0x16b1af459260001

ruok(Are you OK?): 查看当前  zkServer 是否启动,返回 imok(I am OK)

1
2
[root@izbp101vzs716yznuegsljz bin]# echo ruok | nc localhost 2181
imok

dump: 列出未经处理的会话和临时节点

1
2
3
4
5
6
7
8
9
10
11
12
[root@izbp101vzs716yznuegsljz bin]# echo dump | nc localhost 2181
SessionTracker dump:
Session Sets (4):
0 expire at Mon Jun 03 11:11:24 CST 2019:
0 expire at Mon Jun 03 11:11:34 CST 2019:
0 expire at Mon Jun 03 11:11:44 CST 2019:
1 expire at Mon Jun 03 11:11:48 CST 2019:
0x16b1af459260000
ephemeral nodes dump:
Sessions with Ephemerals (1):
0x16b1af459260000:
/test/temg