轉 : 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 到時候可能連不上。
在本機命令列輸入jconsole命令調出介面
在遠端程序中 輸入 主機名:埠號即可
---------------------
作者:冰清雪酷
來源:CSDN
原文:https://blog.csdn.net/luosai19910103/article/details/75574725
版權宣告:本文為博主原創文章,轉載請附上博文連結!