如果读者还没有zookeeper集群环境,可以参考笔者之前的博客,如下:
《zookeeper集群环境配置说明及命令行增删改查操作znode》
在获取zookeeper相关信息时,以下4-字符命令比较方便。
1.命令列表
Category |
Command |
Description |
Server |
ruok |
P straintets. imok if the server is running and not in an error |
conf |
Prints the server configuration (from zoo.cfg). |
|
envi |
Prints the server environment, including ZooKeeper |
|
srvr |
Prints server statistics, including latency statistics, the |
|
stat |
Prints server statistics and connected clients. |
|
srst |
Resets server statistics. |
|
isro |
Shows whether the server is in read-only (ro) mode (due |
|
Client |
dump |
Lists all the sessions and ephemeral znodes for the |
cons |
Lists connection statistics for all the server’s clients. |
|
crst |
Resets connection statistics. |
|
Watches |
wchs |
Lists summary information for the server’s watches. |
wchc |
Lists all the server’s watches by connection. Caution: |
|
wchp |
Lists all the server’s watches by znode path. Caution: |
|
Monitoring |
mntr |
Lists server statistics in Java properties format, suitable |
2.命令使用
使用方法如下:
例如:查看sever是否正常:ruok
echo ruok | nc localhost 2181
如果正常则打印出 imok