且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用Java VisualVM远程监控Tomcat

更新时间:2021-07-05 00:31:03

    1. Tomcat环境变量指定的好习惯

    安装完Tomcat之后,配置CATALINA_HOME和CATALINA_BASE环境变量,如果需要指定环境变量或者JVM参数值,根据catalina.sh文件中的注释说明单独在setenv.sh或者setenv.bat文件中指定,这样catalina.sh在执行的时候会自动读取。

   

   2. 配置启用Tomcat JMX Remote

      Java Visual VM远程监控Tomcat,配置参见:


1
2
3
4
5
6
7
8
JAVA_OPTS="
    -Djava.rmi.server.hostname=192.168.88.29
    -Dcom.sun.management.jmxremote
    -Dcom.sun.management.jmxremote.port=8089
    -Dcom.sun.management.jmxremote.ssl=false
    -Dcom.sun.management.jmxremote.authenticate=true
    -Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password
    -Dcom.sun.management.jmxremote.access.file=../conf/jmxremote.access"

 

    如果authenticate=false的时候不需要配置paasword.file和access.file.否则需要在access.file中指定用户名和读写权限,格式如:

   

1
2
monitorRole readonly
controlRole readwrite


    password.file中指定用户名和密码,格式如:


1
2
monitorRole tomcat
controlRole tomcat

    

    文档中有个小提示:The password file should be read-only and only accessible by the operating system user Tomcat is running as. (意思是password.file的读写权限是400,仅运行tomcat服务的操作系统用户可以访问)


     服务器上启动Tomcat,本地运行jvisual.exe配置JMX,连接远程Tomcat进行监控。

    使用Java VisualVM远程监控Tomcat



本文转自 secondriver 51CTO博客,原文链接:http://blog.51cto.com/aiilive/1730136,如需转载请自行联系原作者