jconsole监控远程spring boot程序

一、定义java环境变量

         1、vim /etc/profile

            在最后一行添加:

export JAVA_OPTS='-Djava.rmi.server.hostname=你的服务器地址 -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、找到你的jvm路径,比如我的是:/usr/lib/jvm

             切换路径:cd /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64/jre/lib/management/

        3、复制一份密码文件并赋予可以写的权限:

             cp    jmxremote.password.template      jmxremote.password

             chomd   +w   jmxremote.password

             

        4、添加账户密码:vim    jmxremote.password

             将最后的两行注释去掉,如下所示:

             

            monitorRole 、controlRole是定义在jmxremote.access中的权限角色,前者只可读,后者可读可写

       5、赋予文件权限:chmod   600    jmxremote.password    jmxremote.access

       6、启动文件:nohup   java   $JAVA_OPTS   -jar   你jar包的名字   >/dev/null     2>&1 &  

       7、netstat   -tunlp   查看端口

       8、在window上找到你的java安装路径找到 jconsole.exe

           

       9、双击打开后填写信息:

                                        jconsole监控远程spring boot程序_第1张图片

       jconsole监控远程spring boot程序_第2张图片

你可能感兴趣的:(java)