VisualVM 远程监控tomcat的配置

远程服务器:CentOS Linux release 7.0.1406
JDK:1.7
TOMCAT:7.0.53

本地:windows 7
JDK 1.7

步骤:
1.在tomcat/bin目录下打开startup.sh,在最后一行前面加如下命令:
export CATALINA_OPTS="$CATALINA_OPTS  
-Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=xxx.xxx.xxx.xxx  -Dcom.sun.management.jmxremote.port=xxx -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.password.file=../conf/jmxremote.password  -Dcom.sun.management.jmxremote.access.file=../conf/jmxremote.access"

其中ip和port修改为自己服务器设置

2.复制/jdk1.6.0_45/jre/lib/management/下面的两个文件jmxremote.access和jmxremote.password.template,复制tomcat/conf文件夹下,并把复制后的jmxremote.password.template改名成jmxremote.password,

3. 然后在tomcat/conf/jmxremote.password后面添加:
username password
在tomcat/conf/jmxremote.access后面添加:
username readwrite

其中,用户名,密码根据情况自己修改。然后执行:chmod 400 ./jmxremote.password命令,修改此文件的权限,否则启动tomcat会出现Error: Password file read access must be restricted:

4. 下载catalina-jmx-remote.jar,去http://archive.apache.org/dist/tomcat/下,根据tomcat的版本,找到bin/extras/目录下的catalina-jmx-remote.jar文件并下载,上传到tomcat/lib目录下

5. 修改/etc/hosts文件,增加如下一行,真实IP是指远程能访问的ip,一般是公网ip,确保新的hosts生效(一般自动生效,如果没生效,自行google解决)
   真实ip localhost

至此,服务端设置完成

启动windows的jdk/bin/jvisualvm.exe文件,选择远程连接,填写远程ip和port,并输入远程连接的用户名和密码(这些都是前面服务端配置的时候设置的)即可。




猜你喜欢

转载自bglmmz.iteye.com/blog/2250235