如何对AIX系统下的JVM里的jar包进行内存监测

如题所述

  使用Java自带的VisualVM监控远程主机JVM内存使用情况
  下面是使用JXM协议配置的简单的操作步骤,详细内容可以阅读文章后的参考资料。
  1.远程主机
  (1)修改JMX服务的配置文件:
  在JDK的根目录/jre/lib/management中,将jmxremote.password.template另存为jmxremote.password。
  用文件编辑软件按编辑jmxremote.password去掉
  # monitorRole QED
  # controlRole R&D
  前面的#注释,保存。
  如果当前系统属于AIX、Linux或者Solaris系统还需要更改jmxremote.access和jmxremote.password的权限
  为只读写,命令如下
  chmod 600 jmxremote.access jmxremote.password

  (2)修改JVM的启动配置信息:
  
  Windows系统
  set JAVA_OPTS=-Dcom.sun.management.jmxremote.port=<port> -Dcom.sun.management.jmxremote.ssl=false
  -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=<hostname>
  -Dcom.sun.management.jmxremote.ssl=false
  
  AIX、Linux或者Solaris
  export JAVA_OPTS="-Dcom.sun.management.jmxremote.port=<port> -Dcom.sun.management.jmxremote.ssl=false
  -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=<hostname>
  -Dcom.sun.management.jmxremote.ssl=false"
  例如:
  set JAVA_OPTS=-Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false
  -Dcom.sun.management.jmxremote.authenticate=false -Djava.rmi.server.hostname=192.168.1.24
  -Dcom.sun.management.jmxremote.ssl=false
  
  配置的说明如下:
  -Dcom.sun.management.jmxremote.port 远程主机端口号的
  -Dcom.sun.management.jmxremote.ssl=false 是否使用SSL连接
  -Dcom.sun.management.jmxremote.authenticate=false 是否开启远程服务权限
  -Djava.rmi.server.hostname 远程主机名,使用IP地址
  
  (3)重启服务。
  
  2.本地主机配置
  方法一、
  进入<JDK_HOME>\bin目录,启动JConsole命令行工具。在JConsole的新连接中添加运程计算机信息。
  <hostname>:<port>或者service:jmx:<protocol>:<sap>
  例如:192.168.1.24:1099或者service:jmx:rmi:///jndi/rmi://192.168.1.24:1099
  <hostname> 检测服务器IP地址
  <port> 运程主机端口
  方法二、
  JDK 1.6以上版本包含了一个简单版本的jvisualvm.exe。在Remote上右键菜单中选择Add Remote host,输入运程计算机Host name,实际上就是要检测的远程计算机IP地址。在配置好的远程主机上右键选择Add JMX Connection...,按照方法一中要求的格式输入,远程主机信息。
温馨提示:答案为网友推荐,仅供参考
相似回答