visualvm connects tomcat remotely through jmx

Recently, the problem of memory overflow was encountered in the project. After the test environment was reproduced, I used visualvm remote connection to monitor it. After the memory overflow problem, I recorded a blog for detailed analysis. Here I only record the use of visualvm to remotely connect tomcat.
I am There are other ways to use jmx for remote connection, so I won't record them one by one here.
  • cd to the server
    quote
    JAVA_HOME/jre/lib/management
    Now, let me say one more thing here, if you don't know the JAVA_HOME on the server, you can pass
    quote
    echo $JAVA_HOME
    or
    quote
    whereis java
    to find the jdk installation directory
  • quote
    chmod 600 jmxremote.password.template
    and
    quote
    management.properties
  • put the directory below
    quote
    jmxremote.password.template
    renamed to
    quote
    jmxremote.password
    , remove the comment from monitorRole QED in its content
  • Modify management.properties
    quote
    com.sun.management.jmxremote.port= (change to the JMX port number you want) com.sun.management.jmxremote.ssl=false, com.sun.management.jmxremote.authenticate=false
    Notes open
  • Find the startup file of tomcat
    quote
    catalina.sh
    , find the JAVA_OPTS item and add it later
    quote
    -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=(JMX port of previous manage.properties) -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate =false -Djava.rmi.server.hostname=(Server's IP)

Even if the modification is completed, start tomcat at this time, and then use netstat -na | grep (jmx port) to see that jmx is successfully started.

Then open the remote of visualvm, add the remote host, and add the server IP, you can detect it The tomcat process is monitored

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326274563&siteId=291194637