ZooKeeper我爱编程程序员

ZooKeeper监控工具(六)

2018-04-03  本文已影响100人  Real_man

之前说了那么多配置信息,具体做的怎么样,还需要真正的获取ZooKeeper的运行时信息才行。这里介绍ZooKeeper的监控。

与文无关

有如下方式:

四字命令

最简单的监控方式就是使用ZooKeeper的四字命令,你可以直接通过telnet或者nc命令查看状态。

四字命令
四字命令
四字命令

常用的四字命令如下:

JMX

JMX是用来远程监控Java应用的框架,这个也可以用来监控其他的Java应用。JMX使用起来也很简单。

在运行Java的jar的时候:

//不需要用户密码的
-Dcom.sun.management.jmxremote.port=5000  
-Dcom.sun.management.jmxremote.authenticate=true 
-Dcom.sun.management.jmxremote.ssl=false 

// 使用需要用户密码登录的
-Dcom.sun.management.jmxremote.port=5000  
-Dcom.sun.management.jmxremote.authenticate=true 
-Dcom.sun.management.jmxremote.ssl=false 
-Dcom.sun.management.jmxremote.access.file=jmxremote.access
-Dcom.sun.management.jmxremote.password.file=jmxremote.password   

➜ cat jmxremote.access
monitorRole   readonly
controlRole   readwrite
➜ cat jmxremote.password
monitorRole mypassword
controlRole mypassword

接下来,我们可以使用jConsole或者VisualVM进行监控。

默认情况下,ZooKeeper允许本地进行监控。


jconsole图

如果想要远程监控,可以修改zkServer.sh文件中的shell脚本


JMX参数图

修改方式为我们刚才看到的加上

-Dcom.sun.management.jmxremote.access.file=jmxremote.access
-Dcom.sun.management.jmxremote.password.file=jmxremote.password   

Exhibitor

Exhibitor是一个ZooKeeper的管理工具,由Netfix公司开发,在ZooKeeper监控,备份恢复,清洁,在可视化上提供了不小的帮助。

  1. 首先我们下载exhibitor的pom文件
mkdir build
cd build 
wget -c https://raw.github.com/Netflix/exhibitor/master/exhibitor-standalone/src/main/resources/buildscripts/standalone/maven/pom.xml
  1. 打包编译jar包
//这个打包的时间真心长
mvn clean package
// 测试是否正确打包,这个exhibitor根据你自己打包出来的文件名进行测试
java -jar target/exhibitor-1.6.0.jar --help       

  1. 运行
java -jar exhibitor-1.6.0.jar -c file
  1. 在浏览器中输入exhibitor的地址
    http://服务器地址:8080/exhibitor/v1/ui/index.html

  2. 配置Exhibitor


    Exhibitor面板
  1. 更多Exhitor的详细信息,参考github的wiki

https://github.com/soabase/exhibitor/wiki

云服务商

当然也有一些云服务商提供ZooKeeper的监控服务,一般都是收费的。
国外的有:server density. 网站:https://www.serverdensity.com/

最后

在看ZooKeeper监控的时候,发现ZooKeeper的监控工具都很老了,大部分都是几年前的了,ZooKeeper这是要被淘汰了吗...,好用的软件应该都有很好用的工具才对。不过既然当初它那么流行,还是有值得研究的地方...

参考

上一篇 下一篇

猜你喜欢

热点阅读