Linux中的命令NetCat有“瑞士军刀”的美誉。我们可以通过nc命令查看Zookeeper的一行属性数据。在Zookeeper中有很多四字命令,汇总如下:
序号 | 使用命令 | 输出说明 |
1 | echo conf | nc 10.9.3.253 2181 | 输出Zookeeper相关服务的详细配置信息,如客户端端口,数据存储路径、最大连接数、日志路径、数据同步端口、主节点推举端口、session超时时间等等 |
2 | echo cons | nc 10.9.3.253 2181 | 输出连接到Zookeeper的服务器信息,包括队列、数据接收量、数据发送量、sessionID、操作延时、最后的操作信息等等 |
3 | echo crst | nc 10.9.3.253 2181 | 重置当前的所有连接、会话等等 |
4 | echo dump | nc 10.9.3.253 2181 | 列出未经处理的会话和连接信息 |
5 | echo envi | nc 10.9.3.253 2181 | 列出zookeeper的版本信息、主机名称、Java版本、java_home、class_path、服务器名称、当前登陆用户名、目录等等; |
6 | echo ruok | nc 10.9.3.253 2181 | Are You Ok的缩写,测试服务器是否正在运行,如果在运行返回imok,否则返回空 |
7 | echo srst | nc 10.9.3.253 2181 | 重置Zookeeper的所有统计信息 |
8 | echo srvr | nc 10.9.3.253 2181 | 列出zookeeper的版本信息、数据接收/发送量、连接数、节点模式、Node数、最大/平均/最小延迟数 |
9 | echo stat | nc 10.9.3.253 2181 | 列出连接客户端列表、最大/平均/最小延迟数、数据接收/发送量、连接数、节点总数、模式 |
10 | echo wchs | nc 10.9.3.253 2181 | 列出watch的总数,连接数 |
11 | echo wchp | nc 10.9.3.253 2181 | 列出所有watch的路径及sessionID |
12 | echo mntr | nc 10.9.3.253 2181 | 列出集群的关键性能数据,包括zk的版本、最大/平均/最小延迟数、数据包接收/发送量、连接数、zk角色(Leader/Follower)、node数量、watch数量、临时节点数 |
1、echo conf | nc 10.9.3.253 2181
clientPort=2181dataDir=/home/zookeeper/zookeeper-3.4.8/data/version-2dataLogDir=/home/zookeeper/zookeeper-3.4.8/data/version-2tickTime=2000maxClientCnxns=60minSessionTimeout=4000maxSessionTimeout=40000serverId=2initLimit=10syncLimit=5electionAlg=3electionPort=2223quorumPort=2222peerType=0
2、echo cons | nc 10.9.3.253 2181
/10.9.3.210:27080[1](queued=0,recved=21379,sent=21379,sid=0x26128063230003a,lop=PING,est=1517842262650,to=6000,lcxid=0x25,lzxid=0x500000e68,lresp=1517885010952,llat=0,minlat=0,avglat=1,maxlat=1832) /10.9.3.2:52081[0](queued=0,recved=1,sent=0) /10.9.3.253:53132[1](queued=0,recved=81690,sent=81690,sid=0x160e4217689000a,lop=PING,est=1516794950707,to=40000,lcxid=0x0,lzxid=0x500000e68,lresp=1517885010871,llat=0,minlat=0,avglat=0,maxlat=3667) /10.9.3.253:41271[1](queued=0,recved=89801,sent=89801,sid=0x260e42176ee0005,lop=GETC,est=1516868422715,to=40000,lcxid=0xd443,lzxid=0x500000e68,lresp=1517885009146,llat=0,minlat=0,avglat=1,maxlat=2328) /127.0.0.1:41248[1](queued=0,recved=21359,sent=21359,sid=0x260e42176ee0534,lop=PING,est=1517842262534,to=6000,lcxid=0xf0,lzxid=0x500000e68,lresp=1517885012461,llat=0,minlat=0,avglat=1,maxlat=1535) /10.9.3.253:53136[1](queued=0,recved=81692,sent=81692,sid=0x160e42176890009,lop=PING,est=1516794950841,to=40000,lcxid=0x5a,lzxid=0x500000e68,lresp=1517885009000,llat=0,minlat=0,avglat=1,maxlat=4846)
3、echo crst | nc 10.9.3.253 2181
Connection stats reset.
4、echo dunp | nc 10.9.3.253 2181
Sessions with Ephemerals (4):0x160e42176890009: /hbase/rs/log1,16020,15156563423190x260e42176ee0005: /hbase/master0x260e42176ee0534: /kafka/controller /kafka/brokers/ids/2530x26128063230003a: /kafka/brokers/ids/210
5、echo envi |nc 10.9.3.253 2181
nvironment:zookeeper.version=3.4.8--1, built on 02/06/2016 03:18 GMThost.name=log1java.version=1.8.0_102java.vendor=Oracle Corporationjava.home=/opt/jdk1.8.0_102/jrejava.class.path=/home/zookeeper/zookeeper-3.4.8/bin/../build/classes:/home/zookeeper/zookeeper-3.4.8/bin/../build/lib/*.jar:/home/zookeeper/zookeeper-3.4.8/bin/../lib/slf4j-log4j12-1.6.1.jar:/home/zookeeper/zookeeper-3.4.8/bin/../lib/slf4j-api-1.6.1.jar:/home/zookeeper/zookeeper-3.4.8/bin/../lib/netty-3.7.0.Final.jar:/home/zookeeper/zookeeper-3.4.8/bin/../lib/log4j-1.2.16.jar:/home/zookeeper/zookeeper-3.4.8/bin/../lib/jline-0.9.94.jar:/home/zookeeper/zookeeper-3.4.8/bin/../zookeeper-3.4.8.jar:/home/zookeeper/zookeeper-3.4.8/bin/../src/java/lib/*.jar:/home/zookeeper/zookeeper-3.4.8/bin/../conf:.:/opt/jdk1.8.0_102/lib/dt.jar:/opt/jdk1.8.0_102/lib/tools.jarjava.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/libjava.io.tmpdir=/tmpjava.compiler=os.name=Linuxos.arch=amd64os.version=2.6.32-431.el6.x86_64user.name=zookeeperuser.home=/home/zookeeperuser.dir=/home/zookeeper/zookeeper-3.4.8/bin
6、echo ruok | nc 10.9.3.253 2181
imok
7、echo srsr | nc 10.9.3.253 2181
Server stats reset.
8、echo srvr | nc 10.9.3.253 2181
Zookeeper version: 3.4.8--1, built on 02/06/2016 03:18 GMTLatency min/avg/max: 0/0/1Received: 160Sent: 160Connections: 6Outstanding: 0Zxid: 0x500000e68Mode: leaderNode count: 200
9、echo stat | nc 10.9.3.253 2181
Zookeeper version: 3.4.8--1, built on 02/06/2016 03:18 GMTClients: /10.9.3.210:27080[1](queued=0,recved=688,sent=688) /10.9.3.253:53132[1](queued=0,recved=103,sent=103) /10.9.3.253:41271[1](queued=0,recved=123,sent=123) /127.0.0.1:41248[1](queued=0,recved=687,sent=687) /10.9.3.2:52642[0](queued=0,recved=1,sent=0) /10.9.3.253:53136[1](queued=0,recved=103,sent=103)Latency min/avg/max: 0/0/1Received: 481Sent: 481Connections: 6Outstanding: 0Zxid: 0x500000e68Mode: leaderNode count: 200
10、echo wchs | nc 10.9.3.253 2181
4 connections watching 19 pathsTotal watches:24
11、echo wchp | nc 10.9.3.253 2181
/kafka/brokers/topics/asda 0x260e42176ee0534/kafka/controller 0x260e42176ee0534 0x26128063230003a/kafka/isr_change_notification 0x260e42176ee0534/kafka/brokers/topics 0x260e42176ee0534/hbase/running 0x260e42176ee0005 0x160e42176890009/kafka/brokers/topics/test 0x260e42176ee0534/hbase/master 0x260e42176ee0005 0x160e42176890009/kafka/config/changes 0x260e42176ee0534 0x26128063230003a/hbase/namespace 0x260e42176ee0005/kafka/brokers/ids 0x260e42176ee0534/hbase/namespace/hbase 0x260e42176ee0005/kafka/admin/reassign_partitions 0x260e42176ee0534/hbase/meta-region-server 0x160e42176890009/hbase/rs/log1,16020,1515656342319 0x260e42176ee0005 0x160e42176890009/hbase/namespace/default 0x260e42176ee0005/hbase/normalizer 0x260e42176ee0005/kafka/admin/delete_topics 0x260e42176ee0534/hbase/balancer 0x260e42176ee0005/kafka/admin/preferred_replica_election 0x260e42176ee0534
12、echo mntr | nc 10.9.3.253 2181
zk_version 3.4.8--1, built on 02/06/2016 03:18 GMTzk_avg_latency 0zk_max_latency 1zk_min_latency 0zk_packets_received 2876zk_packets_sent 2876zk_num_alive_connections 6zk_outstanding_requests 0zk_server_state leaderzk_znode_count 200zk_watch_count 41zk_ephemerals_count 5zk_approximate_data_size 35502zk_open_file_descriptor_count 37zk_max_file_descriptor_count 65536zk_followers 1zk_synced_followers 1zk_pending_syncs 0