Tomcat远程监控功能

来自Linux78|wiki

修改配置文件,开启远程监控

无密方式

vim /application/tomcat8_1/bin/catalina.sh 
CATALINA_OPTS="$CATALINA_OPTS
-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.port=12345  
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false 
-Djava.rmi.server.hostname=10.0.0.17"
ip是你要监控的tomcat所在服务器的ip地址

端口号,是你要开启的监控端口号。

ssl,false表示不使用ssl链接

authenticate,false表示不使用监控,即不需要用户名和密码

密码方式

CATALINA_OPTS=”$CATALINA_OPTS
-Dcom.sun.management.jmxremote
-Djava.rmi.server.hostname=192.168.23.1
-Dcom.sun.management.jmxremote.port=9999
-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,true开启鉴权功能 access.file,权限文件路径 password.file,密码文件路径

当没有配置密码时,无需此操作。当启用密码后,根据上述配置,将 JAVA_HOME/jre/lib/management下面的jmxremote.access和jmxremote.password.template拷贝到Tomcat的conf目录下,并对两个文件做以下修改:

jmxremote.password.template文件名修改为jmxremote.password

修改两个文件的权限

chmod 600 jmxremote.access
chmod 600 jmxremote.password

修改jmxremote.access文件,将文件最后两行显示【monitorRole和controlRole】的注释取消,其中monitorRole为只拥有只读权限的角色,controlRole有更高权限:读写等。编辑完成后,保存。