Introduction
JMX is called Java Management Extension . After opening JMX, you can observe the faults that occur when the tomcat service is running, and monitor the usage of memory and cpu.
JMX configuration
After the tomcat is built, enter the bin directory under tomcat and modify the catalina.sh file
vim catalina.sh
Remote monitoring configuration mode without password
Search for Execute The Requested Command and add the following content below (ip modified to your own):
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=10.1.1.52 -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
Detailed configuration options
server.hostname:ip
jmxremote.port:开启jmx的端口
jmxremote.ssl:是否开启ssl(false/true)
jmxremote.authenticate:是否开启鉴权功能,账号密码远程监控(false/true)
jmxremote.password.file:密码文件路径
jmxremote.access.file:权限文件路径
Remote monitoring configuration with password
Need to open the authentication function (user password login monitoring), modify the following content:
CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=10.1.1.52 -Dcom.sun.management.jmxremote.port=1099 -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"
Enter tomcat conf目录
, create a password file and permission file for the jmx service:
#创建文件
touch jmxremote.password jmxremote.access
#赋值权限
chmod 600 jmx*
Add the following content to the jmxremote.password file:
monitorRole QED
controlRole R&D
Add the following content to the jmxremote.access file:
monitorRole readonly
controlRole readwrite
Verify that JMX is successfully turned on
Enter the bin directory of tomcat, use the script to restart tomcat, and then check whether port 1099 is open:
#重启tomcat
./shutdown.sh
./startup.sh
#查看端口状态
netstat -ant
Monitoring with tools
Use jdk's own tool jvisualvm.exe for connection verification (tool directory: JAVA_HOME/bin), as long as you have JDK installed on your windows machine, there will be this exe.
Enter ip plus port:
if there is a password, enter the password, tick 不要求SSL链接
:
Double-click to open it to monitor the host