JVisualVM监视远程主机Tomcat运行情况

来源:互联网 发布:linux内网穿透知乎 编辑:程序博客网 时间:2024/06/15 18:13
因为Tomcat本身是运行在JVM之上,JVisualVM支持监控Java进程的使用情况(如CPU,堆,线程、类等),所以可以使用JVisualVM来监视指定JVM上Tomcat运行情况。JVisualVM支持JMX的方式连接远程,但是需要修改下JAVA_OPTS。连接过程,我们可以配置简单的用户密码校验。会用到的参数包括

-Dcom.sun.management.jmxremote  //是否启用JMX
-Dcom.sun.management.jmxremote.port=9899 //连接端口
-Dcom.sun.management.jmxremote.authenticate=true //是否认证
-Dcom.sun.management.jmxremote.ssl=false  //是否启用SSL
-Djava.rmi.server.hostname=192.168.1.21  //主机IP
-Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password //密码文件
-Dcom.sun.management.jmxremote.access.file=../conf/jmxremote.access  //用户文件

配置过程如下
[root@centos02 ~] #/usr/local/apache-tomcat-7.0.55/conf
[root@centos02 conf]# vi jmxremote.access
[root@centos02 conf]# vi jmxremote.password
guest readonly
manager readwrite

[root@centos02 conf]# vi jmxremote.password
guest guest
manager manager


[root@centos02 conf]# cd ../bin

[root@centos02 bin]# vi catalina.sh
CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9899 -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=192.168.1.21 -Dcom.sun.management.jmxremote.password.file=/usr/local/apache-tomcat-7.0.55/conf/jmxremote.password -Dcom.sun.management.jmxremote.access.file=/usr/local/apache-tomcat-7.0.55/conf/jmxremote.access"

[root@centos02 conf]# chmod 600 jmx*

[root@centos02 conf]# cd ../bin
[root@centos02 bin]# catalina.sh start

配置连接

连接成功后,可以看到运行情况


原创粉丝点击