jconsole监控远程运行在centos上的spring boot程序

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

[root@localhost management]# cd /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el6_10.x86_64/jre/lib/management/
[root@localhost management]# ls
jmxremote.access  jmxremote.password  jmxremote.password.template  management.properties  snmp.acl.template
[root@localhost management]# cp jmxremote.password.template jmxremote.password
[root@localhost management]# vim jmxremote.password

对于jmxremote.password,将其中的:

#monitorRole  QED
#controlRole  R&D

的注释去掉,改为

monitorRole  QED
controlRole  R&D

QED、R&D为密码,可以自己修改,monitorRole 、controlRole是定义在jmxremote.access中的权限角色,前者只可读,后者可读可写

3.然后配置权限文件为600

[root@localhost management]# chmod 600 jmxremote.password jmxremote.access

4.启动java程序

启动时我们就可以用

nohup java $JAVA_OPTS -jar spider-0.0.1-SNAPSHOT.jar  >nohup 2>&1 &

这个脚本启动java程序了。

查看端口监听情况

netstat -ntulp

《jconsole监控远程运行在centos上的spring boot程序》

5.jconsole远程连接

用上面配置的ip以及端口、账户(角色)、密码远程登录即可

《jconsole监控远程运行在centos上的spring boot程序》

    原文作者:小白龙
    原文地址: https://segmentfault.com/a/1190000016400305
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞