VisualVm使用JMX的方式连接远程JVM

1、在catalina.sh中添加配置如下:

在其中“# ----- Execute The Requested Command -------------”之前插入一行(中间没有换行):

CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8999 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=机器IP"

特别注意:-Djava.rmi.server.hostname=机器IP这一行需要加上,不然可能本机能连上,远程连不上。很多帖子中的介绍配置没有这一行。

2、lsof -i:8999查看端口状态:

3、使用visualVm监控远程虚拟机:相对于使用jstatd的监控,使用jmx的方式会有更多的可以监控的功能,如Threads等。

4、为了安全起见,可以采用配置鉴权的方式,详见参考文献中的介绍。本文不再赘述

参考文献:https://blog.csdn.net/liuxigiant/article/details/40344699

http://tomcat.apache.org/tomcat-7.0-doc/monitoring.html#Enabling_JMX_Remote

原文地址:https://www.cnblogs.com/liclBlog/p/15349471.html