分布式协调服务Zookeeper集群监控JMX和ZkWeb应用对比
分布式协调服务Zookeeper集群监控JMX和ZkWeb应用对比
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
JMX是用来远程监控Java应用的框架,这个也可以用来监控其他的Java应用。JMX使用起来也很简单。当然还有一款比较优秀的监控工具就是ZkWeb,本片博客都会简单介绍部署方式。
JMX官方地址:http://zookeeper.apache.org/doc/r3.4.14/zookeeperJMX.html。
ZkWeb的github地址:https://github.com/zhitom/zkweb
分布式协调服务Zookeeper集群搭建:https://www.cnblogs.com/yinzhengjie/p/10747747.html。
一.zookeeper服务开启JMX监控(不推荐使用该方式)
1>.修改zookeeper的启动脚本
.......... #ZOOMAIN="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=$JMXLOCALONLY org.apache.zookeeper.server.quorum.QuorumPeerMain" #将ZOOMAIN的默认配置注释掉! ZOOMAIN="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false #是否建立远程连接,false可远程建立连接 -Djava.rmi.server.hostname=127.0.0.1 #zookeeper地址 -Dcom.sun.management.jmxremote.port=8888 #JMX连接端口,并不是zookeeper端口,也不能和zookeeper端口冲突 -Dcom.sun.management.jmxremote.ssl=true # 是否ssl连接,如果JMX无法ssl连接上zookeeper,需要改为false -Dcom.sun.management.jmxremote.authenticate=true # 是否开启访问权限,如果设置为true的话,需要指定access和password存放路径,就在下面两行(如果不配置安全认真删除当前行和下面2行即可!) -Dcom.sun.management.jmxremote.access.file=/yinzhengjie/softwares/zookeeper-3.4.14/conf/jmxremote.access # 设置访问权限,需要指定对应的路径,下面哪个文件是指定具体的用户名和密码 -Dcom.sun.management.jmxremote.password.file=/yinzhengjie/softwares/zookeeper-3.4.14/conf/jmxremote.password -Dzookeeper.jmx.log4j.disable=true # 是否开日志 org.apache.zookeeper.server.quorum.QuorumPeerMain" ..........
2>.在“Dcom.sun.management.jmxremote.access.file”和“Dcom.sun.management.jmxremote.password.file”对应的目录下创建相应的文件,结合上面咱们写的文件名称
[root@node101.yinzhengjie.org.cn ~]# cat /yinzhengjie/softwares/zookeeper-3.4.14/conf/jmxremote.access monitorRole readonly controlRole readwrite create javax.management.monitor.*,javax.management.timer.* unregister [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /yinzhengjie/softwares/zookeeper-3.4.14/conf/jmxremote.password monitorRole 123 controlRole 456 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/zookeeper-3.4.14/conf/ | grep jmxremote -rw-r--r--. 1 root root 148 Apr 25 17:09 jmxremote.access -rw-r--r--. 1 root root 34 Apr 25 17:09 jmxremote.password [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# chmod 600 /yinzhengjie/softwares/zookeeper-3.4.14/conf/jmxremote.* [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/zookeeper-3.4.14/conf/ | grep jmxremote -rw-------. 1 root root 148 Apr 25 17:09 jmxremote.access -rw-------. 1 root root 34 Apr 25 17:09 jmxremote.password [root@node101.yinzhengjie.org.cn ~]#
需要注意的是,如果上面修改的2个文件的权限配置为600,会抛出异常,如下图所示:
[root@node102.yinzhengjie.org.cn ~]# cat zookeeper.out Error: Password file read access must be restricted: /yinzhengjie/softwares/zookeeper-3.4.14/conf/jmxremote.password sun.management.AgentConfigurationError at sun.management.jmxremote.ConnectorBootstrap.checkPasswordFile(ConnectorBootstrap.java:577) at sun.management.jmxremote.ConnectorBootstrap.startRemoteConnectorServer(ConnectorBootstrap.java:426) at sun.management.Agent.startAgent(Agent.java:262) at sun.management.Agent.startAgent(Agent.java:452) [root@node102.yinzhengjie.org.cn ~]#
3>.同步配置文件到其他节点中并重启zookeeper集群
[root@node101.yinzhengjie.org.cn ~]# scp -rp /yinzhengjie/softwares/zookeeper-3.4.14/ node102.yinzhengjie.org.cn:/yinzhengjie/softwares/ ...... WatchedEvent.java 100% 2729 7.2MB/s 00:00 VerGen.java 100% 7307 16.8MB/s 00:00 ClientCnxn.java 100% 60KB 65.7MB/s 00:00 AtomicFileOutputStream.java 100% 4608 10.7MB/s 00:00 Time.java 100% 1966 3.9MB/s 00:00 IOUtils.java 100% 3898 9.4MB/s 00:00 PathUtils.java 100% 3740 8.6MB/s 00:00 PathTrie.java 100% 8546 17.1MB/s 00:00 Watcher.java 100% 5895 14.8MB/s 00:00 SaslClientCallbackHandler.java 100% 5447 12.8MB/s 00:00 StatsTrack.java 100% 2773 6.1MB/s 00:00 SaslServerPrincipal.java 100% 4601 9.9MB/s 00:00 ServerAdminClient.java 100% 11KB 19.7MB/s 00:00 AsyncCallback.java 100% 12KB 19.1MB/s 00:00 ManagedUtil.java 100% 2612 5.5MB/s 00:00 ZKMBeanInfo.java 100% 1332 2.1MB/s 00:00 CommonNames.java 100% 1144 2.8MB/s 00:00 MBeanRegistry.java 100% 7326 12.5MB/s 00:00 OpResult.java 100% 5269 2.4MB/s 00:00 ZooKeeper.java 100% 73KB 42.8MB/s 00:00 Environment.java 100% 3443 6.3MB/s 00:00 Op.java 100% 11KB 17.4MB/s 00:00 ZooKeeperTestable.java 100% 1731 4.2MB/s 00:00 ClientCnxnSocketNIO.java 100% 15KB 30.4MB/s 00:00 StaticHostProvider.java 100% 6505 15.3MB/s 00:00 FourLetterWordMain.java 100% 3949 5.9MB/s 00:00 HostProvider.java 100% 2347 5.5MB/s 00:00 ZooKeeperSaslClient.java 100% 20KB 33.7MB/s 00:00 ConnectStringParser.java 100% 2932 7.5MB/s 00:00 Testable.java 100% 1074 2.8MB/s 00:00 MultiTransactionRecord.java 100% 5423 12.7MB/s 00:00 ZooKeeperMain.java 100% 32KB 50.4MB/s 00:00 ClientWatchManager.java 100% 1548 3.8MB/s 00:00 MultiResponse.java 100% 5955 12.9MB/s 00:00 pom.template 100% 1950 5.5MB/s 00:00 NOTICE.txt 100% 3132 8.3MB/s 00:00 lastRevision.bat 100% 1006 2.5MB/s 00:00 LICENSE.txt 100% 12KB 23.6MB/s 00:00 overview.html 100% 1017 3.1MB/s 00:00 lastRevision.sh 100% 910 2.7MB/s 00:00 log4j-1.2.17.LICENSE.txt 100% 11KB 22.4MB/s 00:00 jline-0.9.94.LICENSE.txt 100% 1489 4.5MB/s 00:00 slf4j-1.7.25.LICENSE.txt 100% 1135 3.5MB/s 00:00 README.txt 100% 215 637.1KB/s 00:00 zookeeper_3.1.1.xml 100% 113KB 77.3MB/s 00:00 zookeeper_3.4.14.xml 100% 204KB 86.5MB/s 00:00 zookeeper-env.sh 100% 841 2.3MB/s 00:00 update-zookeeper-env.sh 100% 3817 10.8MB/s 00:00 zookeeper 100% 3760 10.3MB/s 00:00 prerm 100% 1011 1.8MB/s 00:00 conffile 100% 796 1.5MB/s 00:00 control 100% 1153 1.0MB/s 00:00 preinst 100% 1005 3.0MB/s 00:00 postrm 100% 852 2.2MB/s 00:00 postinst 100% 979 2.9MB/s 00:00 zookeeper 100% 1801 5.0MB/s 00:00 zookeeper.spec 100% 6489 10.6MB/s 00:00 log4j-1.2.17.LICENSE.txt 100% 11KB 23.4MB/s 00:00 jline-0.9.94.LICENSE.txt 100% 1489 3.5MB/s 00:00 netty-3.10.6.Final.jar 100% 1262KB 107.0MB/s 00:00 slf4j-api-1.7.25.jar 100% 40KB 44.1MB/s 00:00 slf4j-1.7.25.LICENSE.txt 100% 1135 3.0MB/s 00:00 audience-annotations-0.5.0.jar 100% 20KB 37.2MB/s 00:00 log4j-1.2.17.jar 100% 478KB 100.3MB/s 00:00 slf4j-log4j12-1.7.25.jar 100% 12KB 20.6MB/s 00:00 README.txt 100% 215 497.9KB/s 00:00 zookeeper_3.1.1.xml 100% 113KB 62.6MB/s 00:00 zookeeper_3.4.14.xml 100% 204KB 93.7MB/s 00:00 jline-0.9.94.jar 100% 85KB 72.5MB/s 00:00 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# scp -rp /yinzhengjie/softwares/zookeeper-3.4.14/ node103.yinzhengjie.org.cn:/yinzhengjie/softwares/ ...... StatsTrack.java 100% 2773 6.8MB/s 00:00 SaslServerPrincipal.java 100% 4601 8.7MB/s 00:00 ServerAdminClient.java 100% 11KB 25.2MB/s 00:00 AsyncCallback.java 100% 12KB 21.2MB/s 00:00 ManagedUtil.java 100% 2612 4.9MB/s 00:00 ZKMBeanInfo.java 100% 1332 2.1MB/s 00:00 CommonNames.java 100% 1144 1.1MB/s 00:00 MBeanRegistry.java 100% 7326 16.4MB/s 00:00 OpResult.java 100% 5269 9.8MB/s 00:00 ZooKeeper.java 100% 73KB 64.7MB/s 00:00 Environment.java 100% 3443 9.1MB/s 00:00 Op.java 100% 11KB 25.1MB/s 00:00 ZooKeeperTestable.java 100% 1731 4.7MB/s 00:00 ClientCnxnSocketNIO.java 100% 15KB 28.8MB/s 00:00 StaticHostProvider.java 100% 6505 15.8MB/s 00:00 FourLetterWordMain.java 100% 3949 11.7MB/s 00:00 HostProvider.java 100% 2347 7.2MB/s 00:00 ZooKeeperSaslClient.java 100% 20KB 25.3MB/s 00:00 ConnectStringParser.java 100% 2932 7.3MB/s 00:00 Testable.java 100% 1074 3.5MB/s 00:00 MultiTransactionRecord.java 100% 5423 13.5MB/s 00:00 ZooKeeperMain.java 100% 32KB 43.8MB/s 00:00 ClientWatchManager.java 100% 1548 4.9MB/s 00:00 MultiResponse.java 100% 5955 15.7MB/s 00:00 pom.template 100% 1950 6.3MB/s 00:00 NOTICE.txt 100% 3132 8.1MB/s 00:00 lastRevision.bat 100% 1006 2.4MB/s 00:00 LICENSE.txt 100% 12KB 16.3MB/s 00:00 overview.html 100% 1017 2.6MB/s 00:00 lastRevision.sh 100% 910 2.8MB/s 00:00 log4j-1.2.17.LICENSE.txt 100% 11KB 23.7MB/s 00:00 jline-0.9.94.LICENSE.txt 100% 1489 5.0MB/s 00:00 slf4j-1.7.25.LICENSE.txt 100% 1135 3.1MB/s 00:00 README.txt 100% 215 603.6KB/s 00:00 zookeeper_3.1.1.xml 100% 113KB 69.5MB/s 00:00 zookeeper_3.4.14.xml 100% 204KB 93.3MB/s 00:00 zookeeper-env.sh 100% 841 905.3KB/s 00:00 update-zookeeper-env.sh 100% 3817 6.6MB/s 00:00 zookeeper 100% 3760 10.1MB/s 00:00 prerm 100% 1011 3.5MB/s 00:00 conffile 100% 796 2.3MB/s 00:00 control 100% 1153 3.7MB/s 00:00 preinst 100% 1005 2.8MB/s 00:00 postrm 100% 852 2.2MB/s 00:00 postinst 100% 979 3.1MB/s 00:00 zookeeper 100% 1801 4.9MB/s 00:00 zookeeper.spec 100% 6489 15.8MB/s 00:00 log4j-1.2.17.LICENSE.txt 100% 11KB 25.9MB/s 00:00 jline-0.9.94.LICENSE.txt 100% 1489 5.3MB/s 00:00 netty-3.10.6.Final.jar 100% 1262KB 104.0MB/s 00:00 slf4j-api-1.7.25.jar 100% 40KB 27.0MB/s 00:00 slf4j-1.7.25.LICENSE.txt 100% 1135 2.5MB/s 00:00 audience-annotations-0.5.0.jar 100% 20KB 35.0MB/s 00:00 log4j-1.2.17.jar 100% 478KB 102.9MB/s 00:00 slf4j-log4j12-1.7.25.jar 100% 12KB 21.6MB/s 00:00 README.txt 100% 215 731.0KB/s 00:00 zookeeper_3.1.1.xml 100% 113KB 82.8MB/s 00:00 zookeeper_3.4.14.xml 100% 204KB 97.9MB/s 00:00 jline-0.9.94.jar 100% 85KB 76.1MB/s 00:00 [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# cat /usr/local/bin/xzk.sh #!/bin/bash #@author :yinzhengjie #blog:http://www.cnblogs.com/yinzhengjie #EMAIL:y1053419035@qq.com #判断用户是否传参 if [ $# -ne 1 ];then echo "无效参数,用法为: $0 {start|stop|restart|status}" exit fi #获取用户输入的命令 cmd=$1 #定义函数功能 function zookeeperManger(){ case $cmd in start) echo "启动服务" remoteExecution start ;; stop) echo "停止服务" remoteExecution stop ;; restart) echo "重启服务" remoteExecution restart ;; status) echo "查看状态" remoteExecution status ;; *) echo "无效参数,用法为: $0 {start|stop|restart|status}" ;; esac } #定义执行的命令 function remoteExecution(){ for (( i=101 ; i<=103 ; i++ )) ; do tput setaf 2 echo ========== node${i}.yinzhengjie.org.cn zkServer.sh $1 ================ tput setaf 9 ssh node${i}.yinzhengjie.org.cn "source /etc/profile ; zkServer.sh $1" done } #调用函数 zookeeperManger [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# xzk.sh restart 重启服务 ========== node101.yinzhengjie.org.cn zkServer.sh restart ================ ZooKeeper JMX enabled by default Using config: /yinzhengjie/softwares/zookeeper-3.4.14/bin/../conf/zoo.cfg ZooKeeper JMX enabled by default Using config: /yinzhengjie/softwares/zookeeper-3.4.14/bin/../conf/zoo.cfg Stopping zookeeper ... no zookeeper to stop (could not find file /home/yinzhengjie/zookeeper/zookeeper_server.pid) ZooKeeper JMX enabled by default Using config: /yinzhengjie/softwares/zookeeper-3.4.14/bin/../conf/zoo.cfg Starting zookeeper ... STARTED ========== node102.yinzhengjie.org.cn zkServer.sh restart ================ ZooKeeper JMX enabled by default Using config: /yinzhengjie/softwares/zookeeper-3.4.14/bin/../conf/zoo.cfg ZooKeeper JMX enabled by default Using config: /yinzhengjie/softwares/zookeeper-3.4.14/bin/../conf/zoo.cfg Stopping zookeeper ... no zookeeper to stop (could not find file /home/yinzhengjie/zookeeper/zookeeper_server.pid) ZooKeeper JMX enabled by default Using config: /yinzhengjie/softwares/zookeeper-3.4.14/bin/../conf/zoo.cfg Starting zookeeper ... STARTED ========== node103.yinzhengjie.org.cn zkServer.sh restart ================ ZooKeeper JMX enabled by default Using config: /yinzhengjie/softwares/zookeeper-3.4.14/bin/../conf/zoo.cfg ZooKeeper JMX enabled by default Using config: /yinzhengjie/softwares/zookeeper-3.4.14/bin/../conf/zoo.cfg Stopping zookeeper ... no zookeeper to stop (could not find file /home/yinzhengjie/zookeeper/zookeeper_server.pid) ZooKeeper JMX enabled by default Using config: /yinzhengjie/softwares/zookeeper-3.4.14/bin/../conf/zoo.cfg Starting zookeeper ... STARTED [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# xzk.sh status 查看状态 ========== node101.yinzhengjie.org.cn zkServer.sh status ================ ZooKeeper JMX enabled by default Using config: /yinzhengjie/softwares/zookeeper-3.4.14/bin/../conf/zoo.cfg Mode: follower ========== node102.yinzhengjie.org.cn zkServer.sh status ================ ZooKeeper JMX enabled by default Using config: /yinzhengjie/softwares/zookeeper-3.4.14/bin/../conf/zoo.cfg Mode: leader ========== node103.yinzhengjie.org.cn zkServer.sh status ================ ZooKeeper JMX enabled by default Using config: /yinzhengjie/softwares/zookeeper-3.4.14/bin/../conf/zoo.cfg Mode: follower [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# ss -ntl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 50 172.30.1.101:3888 *:* LISTEN 0 128 *:6000 *:* LISTEN 0 5 192.168.122.1:53 *:* LISTEN 0 128 *:22 *:* LISTEN 0 128 127.0.0.1:631 *:* LISTEN 0 50 *:8888 *:* #我们可以看到JMX端口被启用啦! LISTEN 0 50 *:46079 *:* LISTEN 0 50 *:42687 *:* LISTEN 0 50 *:2181 *:* LISTEN 0 128 :::6000 :::* LISTEN 0 128 :::22 :::* [root@node101.yinzhengjie.org.cn ~]#
参考链接1:https://blog.csdn.net/u013673976/article/details/47321067
参考链接2:https://blog.csdn.net/zk_chs/article/details/84776095#
按照网上的说法我们就可以使用JConsole等工具可以访问该我们配置的JMX端口,可惜我测试了一个下午都没有搞定!不知道是不是我机器有问题,大家是否遇到跟我一样的问题呢?(还好这种监控我没有弄出来,于是我找到了另外的一款监控工具,基于Web的)
二.zookeeper的web监控工具之ZkWeb(官方地址:https://github.com/zhitom/zkweb)
1>.下载“ZkWeb For Zookeeper”的jar包
下载地址:https://github.com/zhitom/zkweb/releases。
2>.运行ZkWeb的jar包(默认启动端口是8099)
[root@node101.yinzhengjie.org.cn ~]# ll total 27876 -rw-r--r--. 1 root root 28541920 Apr 26 16:38 zkWeb-v1.2.1.jar [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# java -jar zkWeb-v1.2.1.jar 16:44:19.229 [main] INFO com.yasenagat.zkweb.ZkWebSpringBootApplication - applicationYamlFileName(application-zkweb.yaml)=file:/root/zkWeb-v1.2.1.jar!/BOOT-INF/classes!/application-zkweb.yaml . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.0.2.RELEASE) [2019-04-26 16:44:20 INFO main StartupInfoLogger.java:50] c.y.zkweb.ZkWebSpringBootApplication --> Starting ZkWebSpringBootApplication vv1.2.1 on node101.yinzhengjie.org.cn with PID 12627 (/root/zkWeb-v1.2.1.jar started by root in /root) [2019-04-26 16:44:20 INFO main SpringApplication.java:663] c.y.zkweb.ZkWebSpringBootApplication --> The following profiles are active: local [2019-04-26 16:44:20 INFO main AbstractApplicationContext.java:590] o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext --> Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@39ba5a14: startup date [Fri Apr 26 16:44:20 CST 2019]; root of context hierarchy [2019-04-26 16:44:22 INFO main DefaultListableBeanFactory.java:824] o.s.b.f.s.DefaultListableBeanFactory --> Overriding bean definition for bean 'requestMappingHandlerAdapter' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=zkSpringBootConfiguration; factoryMethodName=requestMappingHandlerAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/yasenagat/zkweb/util/ZkSpringBootConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration; factoryMethodName=requestMappingHandlerAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]] [2019-04-26 16:44:23 INFO main TomcatWebServer.java:91] o.s.b.w.e.tomcat.TomcatWebServer --> Tomcat initialized with port(s): 8099 (http) [2019-04-26 16:44:23 INFO main DirectJDKLog.java:180] o.a.coyote.http11.Http11NioProtocol --> Initializing ProtocolHandler ["http-nio-8099"] [2019-04-26 16:44:23 INFO main DirectJDKLog.java:180] o.a.catalina.core.StandardService --> Starting service [Tomcat] [2019-04-26 16:44:23 INFO main DirectJDKLog.java:180] o.a.catalina.core.StandardEngine --> Starting Servlet Engine: Apache Tomcat/8.5.31 [2019-04-26 16:44:23 INFO localhost-startStop-1 DirectJDKLog.java:180] o.a.c.core.AprLifecycleListener --> The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib] [2019-04-26 16:44:23 INFO localhost-startStop-1 DirectJDKLog.java:180] o.a.c.c.C.[Tomcat].[localhost].[/] --> Initializing Spring embedded WebApplicationContext [2019-04-26 16:44:23 INFO localhost-startStop-1 ServletWebServerApplicationContext.java:285] o.s.web.context.ContextLoader --> Root WebApplicationContext: initialization completed in 3050 ms [2019-04-26 16:44:23 INFO localhost-startStop-1 ServletRegistrationBean.java:185] o.s.b.w.s.ServletRegistrationBean --> Servlet dispatcherServlet mapped to [/] [2019-04-26 16:44:23 INFO localhost-startStop-1 ServletRegistrationBean.java:185] o.s.b.w.s.ServletRegistrationBean --> Servlet webServlet mapped to [/console/*] [2019-04-26 16:44:23 INFO localhost-startStop-1 ServletRegistrationBean.java:185] o.s.b.w.s.ServletRegistrationBean --> Servlet cacheServlet mapped to [/cache/*] [2019-04-26 16:44:23 INFO localhost-startStop-1 AbstractFilterRegistrationBean.java:244] o.s.b.w.s.FilterRegistrationBean --> Mapping filter: 'characterEncodingFilter' to: [/*] [2019-04-26 16:44:23 INFO localhost-startStop-1 AbstractFilterRegistrationBean.java:244] o.s.b.w.s.FilterRegistrationBean --> Mapping filter: 'hiddenHttpMethodFilter' to: [/*] [2019-04-26 16:44:23 INFO localhost-startStop-1 AbstractFilterRegistrationBean.java:244] o.s.b.w.s.FilterRegistrationBean --> Mapping filter: 'httpPutFormContentFilter' to: [/*] [2019-04-26 16:44:23 INFO localhost-startStop-1 AbstractFilterRegistrationBean.java:244] o.s.b.w.s.FilterRegistrationBean --> Mapping filter: 'requestContextFilter' to: [/*] [2019-04-26 16:44:23 INFO MLog-Init-Reporter Slf4jMLog.java:212] com.mchange.v2.log.MLog --> MLog clients using slf4j logging. [2019-04-26 16:44:23 INFO main Slf4jMLog.java:212] com.mchange.v2.c3p0.C3P0Registry --> Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10] [2019-04-26 16:44:24 INFO main Slf4jMLog.java:212] c.m.v.c.i.AbstractPoolBackedDataSource --> Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> 1br8b51a2on62pc1idrz68|5bd03f44, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> org.h2.Driver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, forceUseNamedDriverClass -> false, identityToken -> 1br8b51a2on62pc1idrz68|5bd03f44, idleConnectionTestPeriod -> 60, initialPoolSize -> 10, jdbcUrl -> jdbc:h2:file:~/.h2/zkweb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=TRUE;FILE_LOCK=SOCKET, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 60, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 20, maxStatements -> 100, maxStatementsPerConnection -> 0, minPoolSize -> 5, numHelperThreads -> 3, preferredTestQuery -> null, privilegeSpawnedThreads -> false, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ] [2019-04-26 16:44:24 ERROR main ZkCfgManagerImpl.java:406] c.y.zkweb.util.ZkCfgManagerImpl --> isTableOk Failed,A problem occurred while trying to acquire a cached PreparedStatement in a background thread. [2019-04-26 16:44:24 ERROR main ZkCfgManagerImpl.java:70] c.y.zkweb.util.ZkCfgManagerImpl --> create table (CREATE TABLE IF NOT EXISTS ZK(ID VARCHAR PRIMARY KEY, DESC VARCHAR, CONNECTSTR VARCHAR, SESSIONTIMEOUT VARCHAR))... [2019-04-26 16:44:24 ERROR main ZkCfgManagerImpl.java:76] c.y.zkweb.util.ZkCfgManagerImpl --> create table OK !ret=0 [2019-04-26 16:44:24 ERROR main ZkCfgManagerImpl.java:81] c.y.zkweb.util.ZkCfgManagerImpl --> table select check OK! [2019-04-26 16:44:24 INFO main ZkCache.java:41] com.yasenagat.zkweb.util.ZkCache --> zk info size=0 [2019-04-26 16:44:24 INFO main ZkCfgManagerImpl.java:436] c.y.zkweb.util.ZkCfgManagerImpl --> afterPropertiesSet init 0 zk instance [2019-04-26 16:44:24 INFO main RequestMappingHandlerAdapter.java:574] o.s.w.s.m.m.a.RequestMappingHandlerAdapter --> Looking for @ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@39ba5a14: startup date [Fri Apr 26 16:44:20 CST 2019]; root of context hierarchy [2019-04-26 16:44:25 INFO main AbstractUrlHandlerMapping.java:373] o.s.w.s.h.SimpleUrlHandlerMapping --> Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] [2019-04-26 16:44:25 INFO main AbstractHandlerMethodMapping.java:547] o.s.w.s.m.m.a.RequestMappingHandlerMapping --> Mapped "{[/zkcfg/queryZkCfgById]}" onto public java.util.Map<java.lang.String, java.lang.Object> com.yasenagat.zkweb.web.ZkCfgController.queryZkCfg(java.lang.String) [2019-04-26 16:44:25 INFO main AbstractHandlerMethodMapping.java:547] o.s.w.s.m.m.a.RequestMappingHandlerMapping --> Mapped "{[/zkcfg/queryZkCfg]}" onto public java.util.Map<java.lang.String, java.lang.Object> com.yasenagat.zkweb.web.ZkCfgController.queryZkCfg(int,int,java.lang.String) [2019-04-26 16:44:25 INFO main AbstractHandlerMethodMapping.java:547] o.s.w.s.m.m.a.RequestMappingHandlerMapping --> Mapped "{[/zkcfg/addZkCfg],produces=[text/html;charset=UTF-8]}" onto public java.lang.String com.yasenagat.zkweb.web.ZkCfgController.addZkCfg(java.lang.String,java.lang.String,java.lang.String) [2019-04-26 16:44:25 INFO main AbstractHandlerMethodMapping.java:547] o.s.w.s.m.m.a.RequestMappingHandlerMapping --> Mapped "{[/zkcfg/updateZkCfg],produces=[text/html;charset=UTF-8]}" onto public java.lang.String com.yasenagat.zkweb.web.ZkCfgController.updateZkCfg(java.lang.String,java.lang.String,java.lang.String,java.lang.String) [2019-04-26 16:44:25 INFO main AbstractHandlerMethodMapping.java:547] o.s.w.s.m.m.a.RequestMappingHandlerMapping --> Mapped "{[/zkcfg/delZkCfg],produces=[text/html;charset=UTF-8]}" onto public java.lang.String com.yasenagat.zkweb.web.ZkCfgController.delZkCfg(java.lang.String) [2019-04-26 16:44:25 INFO main AbstractHandlerMethodMapping.java:547] o.s.w.s.m.m.a.RequestMappingHandlerMapping --> Mapped "{[/zk/queryZnodeInfo],produces=[text/html;charset=UTF-8]}" onto public java.lang.String com.yasenagat.zkweb.web.ZkController.queryzNodeInfo(java.lang.String,org.springframework.ui.Model,java.lang.String) [2019-04-26 16:44:25 INFO main AbstractHandlerMethodMapping.java:547] o.s.w.s.m.m.a.RequestMappingHandlerMapping --> Mapped "{[/zk/queryZKOk]}" onto public java.lang.String com.yasenagat.zkweb.web.ZkController.queryZKOk(org.springframework.ui.Model,java.lang.String) [2019-04-26 16:44:25 INFO main AbstractHandlerMethodMapping.java:547] o.s.w.s.m.m.a.RequestMappingHandlerMapping --> Mapped "{[/zk/queryZKJMXInfo],produces=[application/json;charset=UTF-8]}" onto public java.util.List<com.yasenagat.zkweb.util.ZkManager$PropertyPanel> com.yasenagat.zkweb.web.ZkController.queryZKJMXInfo(java.lang.String,java.lang.String,javax.servlet.http.HttpServletResponse) [2019-04-26 16:44:25 INFO main AbstractHandlerMethodMapping.java:547] o.s.w.s.m.m.a.RequestMappingHandlerMapping --> Mapped "{[/zk/saveData],produces=[text/html;charset=UTF-8]}" onto public java.lang.String com.yasenagat.zkweb.web.ZkController.saveData(java.lang.String,java.lang.String,java.lang.String) [2019-04-26 16:44:25 INFO main AbstractHandlerMethodMapping.java:547] o.s.w.s.m.m.a.RequestMappingHandlerMapping --> Mapped "{[/zk/createNode],produces=[text/html;charset=UTF-8]}" onto public java.lang.String com.yasenagat.zkweb.web.ZkController.createNode(java.lang.String,java.lang.String,java.lang.String) [2019-04-26 16:44:25 INFO main AbstractHandlerMethodMapping.java:547] o.s.w.s.m.m.a.RequestMappingHandlerMapping --> Mapped "{[/zk/deleteNode],produces=[text/html;charset=UTF-8]}" onto public java.lang.String com.yasenagat.zkweb.web.ZkController.deleteNode(java.lang.String,java.lang.String) [2019-04-26 16:44:25 INFO main AbstractHandlerMethodMapping.java:547] o.s.w.s.m.m.a.RequestMappingHandlerMapping --> Mapped "{[/zk/queryZnode]}" onto public java.util.List<com.yasenagat.zkweb.model.Tree> com.yasenagat.zkweb.web.ZkController.query(java.lang.String,java.lang.String,java.lang.String) [2019-04-26 16:44:25 INFO main AbstractHandlerMethodMapping.java:547] o.s.w.s.m.m.a.RequestMappingHandlerMapping --> Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) [2019-04-26 16:44:25 INFO main AbstractHandlerMethodMapping.java:547] o.s.w.s.m.m.a.RequestMappingHandlerMapping --> Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest) [2019-04-26 16:44:25 INFO main AbstractUrlHandlerMapping.java:360] o.s.w.s.h.SimpleUrlHandlerMapping --> Root mapping to handler of type [class org.springframework.web.servlet.mvc.ParameterizableViewController] [2019-04-26 16:44:25 INFO main AbstractUrlHandlerMapping.java:373] o.s.w.s.h.SimpleUrlHandlerMapping --> Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] [2019-04-26 16:44:25 INFO main AbstractUrlHandlerMapping.java:373] o.s.w.s.h.SimpleUrlHandlerMapping --> Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] [2019-04-26 16:44:25 INFO main AbstractUrlHandlerMapping.java:373] o.s.w.s.h.SimpleUrlHandlerMapping --> Mapped URL path [/resources/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] [2019-04-26 16:44:25 INFO main MBeanExporter.java:433] o.s.j.e.a.AnnotationMBeanExporter --> Registering beans for JMX exposure on startup [2019-04-26 16:44:25 INFO main DirectJDKLog.java:180] o.a.coyote.http11.Http11NioProtocol --> Starting ProtocolHandler ["http-nio-8099"] [2019-04-26 16:44:25 INFO main DirectJDKLog.java:180] o.a.tomcat.util.net.NioSelectorPool --> Using a shared selector for servlet write/read [2019-04-26 16:44:25 INFO main DirectJDKLog.java:180] o.a.c.c.C.[Tomcat].[localhost].[/] --> Initializing Spring FrameworkServlet 'dispatcherServlet' [2019-04-26 16:44:25 INFO main FrameworkServlet.java:494] o.s.web.servlet.DispatcherServlet --> FrameworkServlet 'dispatcherServlet': initialization started [2019-04-26 16:44:25 INFO main FrameworkServlet.java:509] o.s.web.servlet.DispatcherServlet --> FrameworkServlet 'dispatcherServlet': initialization completed in 16 ms [2019-04-26 16:44:25 INFO main TomcatWebServer.java:206] o.s.b.w.e.tomcat.TomcatWebServer --> Tomcat started on port(s): 8099 (http) with context path '' [2019-04-26 16:44:25 INFO main StartupInfoLogger.java:59] c.y.zkweb.ZkWebSpringBootApplication --> Started ZkWebSpringBootApplication in 6.499 seconds (JVM running for 7.016) [2019-04-26 16:48:35 INFO http-nio-8099-exec-8 ZkCfgController.java:36] c.y.zkweb.web.ZkCfgController --> Fri Apr 26 16:48:35 CST 2019 [2019-04-26 16:48:35 INFO http-nio-8099-exec-8 ZkCfgManagerImpl.java:285] c.y.zkweb.util.ZkCfgManagerImpl --> whereSq=desc like '%%'
3>.成功添加一个节点
4>.查看添加节点的信息
5>.我们可以使用他提供的web界面操作zookeeper集群哟!