1、啟動java進程的命令
在啟動命令中添加如下信息
-Djava.rmi.server.hostname=192.169.1.71 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=10099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
說明
-Djava.rmi.server.hostname為java程序運行所在的機器ip
-Dcom.sun.management.jmxremote.port為端口,自定義,保證是未使用的端口即可。jconsole通過這個端口來連接。
-Dcom.sun.management.jmxremote.authenticate=false表示在jconsole連接時可以不用輸入賬號和密碼
示例
nohup java -Xms128M -Xmx256M -Djava.rmi.server.hostname=192.169.1.71 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=10099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -jar appgateway-1.0.0.9.jar --spring.config.location=/usr/local/csnsh/ums/appgateway/application-appgateway.properties >appgateway.txt &
2、使用jconsole通過啟動命令中的ip和端口進行連接
參考地址
jconsole遠程監控linux上的springBoot服務:https://blog.csdn.net/myfmyfmyfmyf/article/details/88288388