jconsole and jvisualvm remote monitoring tomcat

           Recently, I used jdk-related auxiliary tools to analyze the problem of abnormally high cpu caused by tomcat. Today, I took the time to write about jconsole and jvisualvm remote monitoring tomcat configuration, and then I will write a specific monitoring and analysis blog post (including the use of jstack, I will write it later when I take time) , jconsole and jvisualvm remote monitoring tomcat configuration The specific steps are as follows:

 

  1. Log in to the linux server deployed by tomcat

  2. Edit tomcat/bin/catalina.sh, add remote configuration, the configuration location is as follows:



      

    The configuration item value is:

    CATALINA_OPTS="-Djava.rmi.server.hostname=192.168.32.130 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true"

    This configuration is mainly to provide external remote access port and hostname , and configure items such as authentication

     

  3. Edit jmxremote.access and jmxremote.password

    The main purpose here is to modify the jmxremote.password file, but do not change jmxremote.access . The storage path of the two files is in the /jre/lib/management directory of jdk



      

    If there is no jmxremote.password but only jmxremote.password.template , just copy the file and rename it, and then modify   vim jmxremote.password , the modification point is to release the note at the bottom of the file, and customize the password. The front is the user role, followed by the access password, as follows:

    monitorRole  mzxwswj

    controlRole mzxwswj



      

  4. Add the port to the firewall trust list

    Edit vi /etc/sysconfig/iptables directly and add a new line:

    -A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 12345 -j ACCEPT

    Note that this port must be the same as the one configured in catalina.sh



      

  5. start tomcat

    Execute ./startup.sh in the tomcat/bin directory



      

    Because the remote 12345 port service I configured will be automatically started when tomcat starts , so I need to check it through the command, the command is: netstat -an | grep 12345



      

     

  6. jvisualvm connects to the remote tomcat service

    Find jvisualvm.exe in the jdk/bin directory on your local computer , and then set up the remote connection, as shown below:



      

    登录后就可以对其进行相应的监控了,如下图:



      

     

  7. jconsole连接远程tomcat服务

    同样在自己本地电脑上jdk/bin目录下找到jconsole.exe,然后进行远程连接设置,如下图:



      

    登录后就可以对其进行相应的监控了,如下图:



      

     

  8. 易错点

    防火墙问题:

    systemctl stop firewalld.service

    Tomcat启动失败:

    切换到tomcat/logs目录下,查看日志文件catalina.out对错误信息进行分析

 

    登录用户、密码不对

    monitorRole  mzxwswj
    controlRole   mzxwswj

 

Guess you like

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