jconsole監控遠端執行在centos上的spring boot程式
阿新 • • 發佈:2018-12-09
1.定義環境變數
由於需要設定的java啟動引數較多,故而將其設定到環境變數中,在/etc/profile 最後一行增加
export JAVA_OPTS='-Djava.rmi.server.hostname=192.105.90.192 -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8888 -Dcom.sun.management.jmxremote.rmi.port=8888 -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.ssl=false'
然後 source /etc/profile 是檔案生效。
2.修改許可權檔案
複製jmxremote.password.template,並重名為jmxremote.password
[[email protected] management]# pwd
/usr/local/src/jdk1.8.0_131/jre/lib/management
[[email protected] management]# ls
jmxremote.access jmxremote.password jmxremote.password.template management.properties snmp.acl.template
[ [email protected] management]# cp jmxremote.password.template jmxremote.password
[[email protected] management]# vim jmxremote.password
對於jmxremote.password,將其中的:
#monitorRole QED
#controlRole R&D
的註釋去掉,改為
monitorRole QED
controlRole R&D
QED、R&D為密碼,可以自己修改,monitorRole 、controlRole
3.然後配置許可權檔案為600
[[email protected] management]# chmod 600 jmxremote.password jmxremote.access
4.啟動java程式
啟動時我們就可以用
nohup java $JAVA_OPTS -jar /root/app/data-center-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev >nohup 2>&1 &
這個指令碼啟動java程式了。
5.jconsole遠端連線
用上面配置的ip以及埠、賬戶、密碼遠端登入即可