1. VisualVM 项目页下载 VisualVM 安装程序。

  2. 将 VisualVM 安装程序解压缩到本地系统。

  3. 导航至 VisualVM 安装目录的 bin 目录,然后启动应用程序。

  4. 添加远程主机IP

  5. 在服务器上启动jstatd脚本,默认监听1099端口

    #!/bin/sh

   policy=${HOME}/.jstatd.all.policy

   host=`ifconfig|egrep -A 1 "(eth[0-9]|em[0-9])"|sed '/eth/d;/--/d;s/.*inet addr:\([^         ]\+\).*/\1/g'|egrep "(10.|192.)" `

   [ -r ${policy} ] || cat >${policy} <<'POLICY'


   grant codebase "file:${java.home}/../lib/tools.jar" {

   permission java.security.AllPermission;

   };

   POLICY

   jstatd -J-Djava.security.policy=${policy}  -J-Djava.rmi.server.hostname=${host}  &

6.  在resin.conf中配置jmx设置,重启resin监听jmx端口

   (resin3.1.10版本)

     <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>

     <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>

     <jvm-arg>-Dcom.sun.management.jmxremote.port=9999</jvm-arg>

     <jvm-arg>-Dcom.sun.management.jmxremote.ssl=false</jvm-arg>

     <jvm-arg>-Dcom.sun.management.jmxremote.authenticate=false</jvm-arg>

7.  添加jmx、和jstatd连接,需要注意防火墙设置,因为与jstatd连接需要开启1099端口和63896端口

显示结果如下图,会扫描到服务器上启动的java进程

225653153.jpg