jconsole 和jvisualVM 监控远程 spring boot程序

监控java 程序 增加启动参数 

java  

-Djava.rmi.server.hostname=192.168.2.39

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=1099
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-jar /root/app/data-test-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev  >nohup 2>&1 & 

由于启动参数过长,我们可以定义系统环境变量来表示 在/etc/profile 最后一行增加 

export JAVA_OPTS='-Djava.rmi.server.hostname=192.168.2.39 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false'

然后 source /etc/profile 是文件生效。

启动时我们就可以用  nohup java $JAVA_OPTS -jar /root/app/data-center-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev  >nohup 2>&1 & 这个脚本。 

JMX端口为1099 ;

如果不设置服务器主机名 -Djava.rmi.server.hostname 到时候可能连不上。

1.在本机命令行输入jconsole命令调出界面

在远程进程中 输入 主机名:端口号即可

 2.jvisualvm 首先建立远程连接,在新建好的远程连接右击,创建jmx连接

原文地址:https://www.cnblogs.com/shengs/p/10796518.html