一、安装VisualVM
方式一:idea安装VisualVM插件
File-> Setting-> Plugins -> Browers Repositrories 搜索VisualVM Launcher安装并重启IDEA
方式二:scoop 安装VisualVM
scoop search VisualVM
scoop insall visualvm
二 、远程连接JVM
1、添加启动参数:
JAVA_OPTS="
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9999
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Djava.rmi.server.hostname=192.168.187.139
-Dcom.sun.management.jmxremote.rmi.port=9999
"
2、参数项解释
-Djava.rmi.server.hostname=192.168.187.139
远程服务器的主机名
-Dcom.sun.management.jmxremote
是否支持远程JMX访问
默认:true;
-Dcom.sun.management.jmxremote.port
JMX远程监控端口号
需要在防火墙开放该端口
-Dcom.sun.management.jmxremote.ssl=false
表示是否对连接开启SSL加密
默认:开启
-Dcom.sun.management.jmxremote.authenticate=false
是否需要开启用户认证
默认:开启
如果开启需要额外配置授权文件
-Dcom.sun.management.jmxremote.rmi.port=9999
RMI端口号(远程连接的端口)
JMX在远程连接时,会随机开启一个RMI端口作为连接的数据端口
可以和JMX端口号相同
这里我们指定了RMI的端口号
3、启动VisualVM建立远程连接