淘先锋技术网

首页 1 2 3 4 5 6 7

四字命令执行方式

echo <command> | nc <zookeeper_ip> <zookeeper_port>

四字命令列表

conf

打印服务端配置信息(3.3.0版本引入)

clientPort=2181
dataDir=/opt/zkCluster/zookeeper01/./data/version-2
dataLogDir=/opt/zkCluster/zookeeper01/./datalog/version-2
tickTime=2000
maxClientCnxns=60
minSessionTimeout=4000
maxSessionTimeout=40000
serverId=1
initLimit=10
syncLimit=5
electionAlg=3
electionPort=22222
quorumPort=2222
peerType=0

cons

展示所有连接到当然zk节点的连接/会话细节信息,包括接收/发送的包的数量,会话ID,延迟,最后的操作等等(3.3.0版本引入)

 /0:0:0:0:0:0:0:1:56326[1](queued=0,recved=6,sent=6,sid=0x100a5badba30000,lop=GETC,est=1557132448123,to=30000,lcxid=0x1,lzxid=0x1300000001,lresp=2799687604,llat=20,minlat=0,avglat=31,maxlat=169)
 /0:0:0:0:0:0:0:1:56352[0](queued=0,recved=1,sent=0)

crst

重置所有连接/会话的统计信息(3.3.0版本引入)

Connection stats reset.

dump

展示所有在等待的会话和所有临时节点,等待会话只对leader节点生效

SessionTracker dump:
Session Sets (3):
0 expire at Mon Feb 02 17:52:36 CST 1970:
0 expire at Mon Feb 02 17:52:46 CST 1970:
1 expire at Mon Feb 02 17:52:56 CST 1970:
	0x100a5badba30000
ephemeral nodes dump:
Sessions with Ephemerals (1):
0x100a5badba30000:
	/temp-333
	/temp-222
	/temp-111

envi

打印服务端环境信息

Environment:
zookeeper.version=3.4.14-4c25d480e66aadd371de8bd2fd8da255ac140bcf, built on 03/06/2019 16:18 GMT
host.name=172.18.223.204
java.version=1.8.0_131
java.vendor=Oracle Corporation
java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre
java.class.path=/opt/zkCluster/zookeeper01/bin/../zookeeper-server/target/classes:/opt/zkCluster/zookeeper01/bin/../build/classes:/opt/zkCluster/zookeeper01/bin/../zookeeper-server/target/lib/*.jar:/opt/zkCluster/zookeeper01/bin/../build/lib/*.jar:/opt/zkCluster/zookeeper01/bin/../lib/slf4j-log4j12-1.7.25.jar:/opt/zkCluster/zookeeper01/bin/../lib/slf4j-api-1.7.25.jar:/opt/zkCluster/zookeeper01/bin/../lib/netty-3.10.6.Final.jar:/opt/zkCluster/zookeeper01/bin/../lib/log4j-1.2.17.jar:/opt/zkCluster/zookeeper01/bin/../lib/jline-0.9.94.jar:/opt/zkCluster/zookeeper01/bin/../lib/audience-annotations-0.5.0.jar:/opt/zkCluster/zookeeper01/bin/../zookeeper-3.4.14.jar:/opt/zkCluster/zookeeper01/bin/../zookeeper-server/src/main/resources/lib/*.jar:/opt/zkCluster/zookeeper01/bin/../conf:
java.library.path=/Users/xxx/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
java.io.tmpdir=/var/folders/xw/0b0db9nx7z12g_tjwc57s2m80000gn/T/
java.compiler=<NA>
os.name=Mac OS X
os.arch=x86_64
os.version=10.14
user.name=xxx
user.home=/Users/xxx
user.dir=/opt/zkCluster/

ruok

测试zk服务端是否允许正常,正常则返回“imok”,否则不会返回任何结果。返回“imok”并不意味着节点已经加入集群,只是意味着zk进程正常启动、绑定端口。建议使用“stat”获取更多集群和连接信息。

imok

srst

重置服务端统计信息

Server stats reset.

srvr

展示zk服务端信息(3.3.0版本引入)

Zookeeper version: 3.4.14-4c25d480e66aadd371de8bd2fd8da255ac140bcf, built on 03/06/2019 16:18 GMT
Latency min/avg/max: 0/0/1
Received: 17
Sent: 17
Connections: 2
Outstanding: 0
Zxid: 0x1300000004
Mode: follower
Node count: 276397

stat

展示服务端概要信息和已连接的客户端

Zookeeper version: 3.4.14-4c25d480e66aadd371de8bd2fd8da255ac140bcf, built on 03/06/2019 16:18 GMT
Clients:
 /0:0:0:0:0:0:0:1:56326[1](queued=0,recved=173,sent=173)
 /0:0:0:0:0:0:0:1:58650[0](queued=0,recved=1,sent=0)

Latency min/avg/max: 0/0/1
Received: 34
Sent: 34
Connections: 2
Outstanding: 0
Zxid: 0x1300000004
Mode: follower
Node count: 276397

wchs

展示watcher概要信息 (3.3.0版本引入)

0 connections watching 0 paths
Total watches:0

wchc

按session展示watcher细节信息,该操作可能会对服务端性能产生影响(取决于watcher的数量),慎用!(3.3.0版本引入)

dirs

展示snapshot和log文件总大小( 3.5.1版本引入)

wchp

按path展示watcher细节信息,该操作可能会对服务端性能产生影响(取决于watcher的数量),慎用!(3.3.0版本引入)

mntr

输出一串变量信息,可用于监控集群的健康状况(3.4.0版本引入)

zk_version	3.4.14-4c25d480e66aadd371de8bd2fd8da255ac140bcf, built on 03/06/2019 16:18 GMT
zk_avg_latency	0
zk_max_latency	1
zk_min_latency	0
zk_packets_received	146
zk_packets_sent	146
zk_num_alive_connections	2
zk_outstanding_requests	0
zk_server_state	follower
zk_znode_count	276397
zk_watch_count	0
zk_ephemerals_count	3
zk_approximate_data_size	2414043
zk_open_file_descriptor_count	39
zk_max_file_descriptor_count	10240
zk_fsync_threshold_exceed_count	0