JVisualVM监视远程主机Tomcat运行情况
因为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 //用户文件
配置过程如下
[[email protected] ~] #/usr/local/apache-tomcat-7.0.55/conf
[[email protected] conf]# vi jmxremote.access
[[email protected] conf]# vi jmxremote.password
guest readonly
manager readwrite
[[email protected] conf]# vi jmxremote.password
guest guest
manager manager
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"
[[email protected] bin]# catalina.sh start
-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 //用户文件
配置过程如下
[[email protected] ~] #/usr/local/apache-tomcat-7.0.55/conf
[[email protected] conf]# vi jmxremote.access
[[email protected] conf]# vi jmxremote.password
guest readonly
manager readwrite
[[email protected] conf]# vi jmxremote.password
guest guest
manager manager
[[email protected] conf]# cd ../bin
[[email protected] bin]# vi catalina.shCATALINA_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"
[[email protected] conf]# chmod 600 jmx*
[[email protected] conf]# cd ../bin[[email protected] bin]# catalina.sh start
配置连接
连接成功后,可以看到运行情况