zookeepeer4字命令实践
环境
leader:192.168.116.143
fllower:192.168.116.142
fllower:192.168.116.144
命令:conf——查看其他主机的配置文件
1 [root@sxl132 Desktop]# echo conf | nc 192.168.116.144 2181
2 clientPort=2181
3 dataDir=/usr/data/zookeepeer/version-2
4 dataLogDir=/usr/data/zookeepeer/version-2
5 tickTime=2000
6 maxClientCnxns=60
7 minSessionTimeout=4000
8 maxSessionTimeout=40000
9 serverId=4
10 initLimit=10
11 syncLimit=5
12 electionAlg=3
13 electionPort=3888
14 quorumPort=2888
15 peerType=0
命令:ruok——查看其他主机是否存活
1 [root@sxl132 Desktop]# echo ruok | nc 192.168.116.144 2181
2 imok[root@sxl132 Desktop]#
命令:cons——查看连接信息
1 [root@sxl132 Desktop]# echo cons | nc 192.168.116.144 2181
2 /192.168.116.142:44336[0](queued=0,recved=1,sent=0)
命令:dump——查看未处理的会话节点
1 Desktop]# echo dump | nc 192.168.116.144 2181
2 SessionTracker dump:
3 org.apache.zookeeper.server.quorum.LearnerSessionTracker@731f57b1
4 ephemeral nodes dump:
5 Sessions with Ephemerals (0):
命令:reqs——查看未处理的请求
1 [root@sxl132 Desktop]# echo reqs | nc 192.168.116.144 2181 //当然,这里没有未处理的请求
命令:stat——查看统计信息
1 [root@sxl132 Desktop]# echo stat | nc 192.168.116.144 2181
2 Zookeeper version: 3.4.11-37e277162d567b55a07d1755f0b31c32e93c01a0, built on 11/01/2017 18:06 GMT
3 Clients:
4 /192.168.116.142:44342[0](queued=0,recved=1,sent=0)
5
6 Latency min/avg/max: 0/0/0
7 Received: 6
8 Sent: 5
9 Connections: 1
10 Outstanding: 0
11 Zxid: 0x600000000
12 Mode: follower
13 Node count: 4
命令:envi——查看环境信息
1 [root@sxl132 Desktop]# echo envi | nc 192.168.116.144 2181
2 Environment:
3 zookeeper.version=3.4.11-37e277162d567b55a07d1755f0b31c32e93c01a0, built on 11/01/2017 18:06 GMT
4 host.name=localhost
5 java.version=1.8.0_151
6 java.vendor=Oracle Corporation
7 java.home=/usr/app/java/jdk/jre
8 java.class.path=/usr/app/zookeepeer/bin/../build/classes:/usr/app/zookeepeer/bin/../build/lib/*.jar:/usr/app/zookeepeer/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/app/zookeepeer/bin/../lib/slf4j-api-1.6.1.jar:/usr/app/zookeepeer/bin/../lib/netty-3.10.5.Final.jar:/usr/app/zookeepeer/bin/../lib/log4j-1.2.16.jar:/usr/app/zookeepeer/bin/../lib/jline-0.9.94.jar:/usr/app/zookeepeer/bin/../lib/audience-annotations-0.5.0.jar:/usr/app/zookeepeer/bin/../zookeeper-3.4.11.jar:/usr/app/zookeepeer/bin/../src/java/lib/*.jar:/usr/app/zookeepeer/bin/../conf:/usr/app/java/jdk/lib/
9 java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
10 java.io.tmpdir=/tmp
11 java.compiler=<NA>
12 os.name=Linux
13 os.arch=amd64
14 os.version=2.6.32-431.el6.x86_64
15 user.name=root
16 user.home=/root
17 user.dir=/usr/app/zookeepeer
命令:wchs——查看服务器watch的详细信息
1 [root@sxl132 Desktop]# echo wchs | nc 192.168.116.144 2181
2 0 connections watching 0 paths
3 Total watches:0
命令:wchp——列出指定路径下的服务器信息
1 [root@sxl132 Desktop]# echo wchp | nc localhost 2181
2 wchp is not executed because it is not in the whitelist.
这里没有权限,因为不在白名单,目前还不知道怎么设置,可以在zookeepeer的官网可查看这方面的资料:http://zookeeper.apache.org/doc/r3.4.10/zookeeperAdmin.html
还有一些4字命令,可以查看zookeepeer的官网。
PS:linux命令中的竖线|是一个管道,可以把命令右边的内容传递给左边。
参考文档
1、徐培成的大数据——zookeepeer视频
2、http://zookeeper.apache.org/doc/r3.4.10/zookeeperAdmin.html#sc_zkCommands (Zookeepeer的4字命令)