zoukankan      html  css  js  c++  java
  • JvisualVM、JMC监控远程服务器

    1. 修改服务器上jmxremote.access与jmxremote.password,输入命令:
       find -name jmxremote.access


      进入该jmxremote.access文件所在目录中,输入命令:
      cd /usr/java/jdk1.8.0_91/jre/lib/management 

      路径要用到两个文件:(jmxremote.access和jmxremote.password)
      mv jmxremote.access.template jmxremote.access如果 jmxremote.access文件不存在,只有 jmxremote.access.template 文件时,需创建 该文件
      vi jmxremote.access


      mv jmxremote.password.template jmxremote.password  如果 jmxremote.password 文件不存在,只有 jmxremote.password.template 文件时,需创建 该文件
      vi jmxremote.password  


    2. 启动相应jar文件
      java -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=端口 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -Djava.rmi.server.hostname=172.16.103.115 -jar jar包名

      例如

      java -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=7091 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -Djava.rmi.server.hostname=172.16.103.115 -jar SpringMVCDemo-0.0.1-SNAPSHOT.jar


      java -Xms200m -Xmx1024m 
      -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=7091 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -Djava.rmi.server.hostname=172.16.103.115 -jar SpringMVCDemo-0.0.1-SNAPSHOT.jar

    3. 本机启动JvisualVM
      在 JDK的bin目录下双击jvisualvm.exe启动

    4. 在JavaVisuaVM中右击远程 -> 远程添加主机


    5. 右击该远程主机 -> 添加JMX连接

    6. 监控见面如下:
    7. 查看线程DUMP
       右击JMX连接图标,线程DUMP


      8堆DUMP
      右击jmx,堆dump,

      从远程机拷到本地

      文件 -> 装入

      就能看堆dump


      9. 堆比较




    添加jmx启动参数,踩过的坑

    添加jmx 参数

    -Dcom.sun.management.jmxremote=true 
    -Dcom.sun.management.jmxremote.port=123456 
    -Dcom.sun.management.jmxremote.authenticate=false 
    -Dcom.sun.management.jmxremote.ssl=false 
    -XX:+UnlockCommercialFeatures 
    -XX:+FlightRecorder 
    -Djava.rmi.server.hostname=172.16.103.127

    1.jmxremote.password和jmxremote.access 权限问题

    注意:jmxremote.password和jmxremote.access文件只允许启动用户名对该文件拥有读写权限 ,

    权限不对,会报:

    Error: Password file read access must be restricted: /usr/java/jdk1.8.0_91/jre/lib/management/jmxremote.password
    Error: Password file read access must be restricted: /usr/java/jdk1.8.0_91/jre/lib/management/jmxremote.password

    调整文件权限

    [root@dog:management]# chmod 600 *

    [root@dog:management]# chown root:root *
    [root@dog:management]# ll

    2.添加jmx 启动参数,导致启动shell 脚本里格式不正确

    Error: Could not find or load main class
    Error: Could not find or load main class

    开始是直接将启动参数贴到启动shell脚本,导致启动失败。

    手工一行一行添加参数后,定位到最后一行-Djava.rmi.server.hostname=172.16.103.127 参数 可能是编码,格式的问题。

    手动将ip地址敲进去,问题解决。

  • 相关阅读:
    2017 Multi-University Training Contest 2.Balala Power!(贪心)
    2017ICPCECIC C.A math problem(高次剩余)
    Atcoder 068E
    51nod 1385 凑数字(贪心+构造)
    cf round #418 div2 D. An overnight dance in discotheque(贪心)
    cf round #418 div2 C. An impassioned circulation of affection(暴力)
    cf round #424 div2 E. Cards Sorting(线段树)
    Atcoder 077E
    hdu 6162 Ch’s gift(树链剖分+主席树)
    Educational Codeforces Round 26 D. Round Subset(dp)
  • 原文地址:https://www.cnblogs.com/chenjiazhu/p/6308540.html
Copyright © 2011-2022 走看看