监控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
版权声明:本文为博主原创文章,转载请附上博文链接!