使用本地JConsole监控远程linux下JVM

原文:http://www.linuxidc.com/Linux/2015-02/113420.htm   使用本地JConsole监控远程JVM(最权威的总结)

http://my.oschina.net/u/1164238/blog/135866 (Jconsole远程连接)

 http://www.cnblogs.com/sunxucool/p/4059040.html ()

 

 

 

步骤如下:

1.编辑tomcat/bin/catalina.sh

在其中“

# ----- Execute The Requested Command -----------------------------------------”

 

扫描二维码关注公众号,回复: 653831 查看本文章

之前插入新的一行(中间没有换行),内容如下:

CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote 

-Dcom.sun.management.jmxremote.port=9099 

-Djava.rmi.server.hostname=172.17.123.134 

-Dcom.sun.management.jmxremote.authenticate=true 

-Dcom.sun.management.jmxremote.ssl=false 

-Dcom.sun.management.jmxremote.access.file=/usr/java/jdk1.7.0_75/jre/lib/management/jmxremote.access 

-Dcom.sun.management.jmxremote.password.file=/usr/java/jdk1.7.0_75/jre/lib/management/jmxremote.password"

export JAVA_OPTS

 

-Dcom.sun.management.jmxremote.authenticate=false 则可以不要最后的access.file和 password.file文件;

 

2.编辑jmxremote.access和jmxremote.password

   在远程的linux服务器上的jdk下:/usr/java/jdk1.7.0_75/jre/lib/management/目录下有jmxremote.access,不用管,直接将jmxremote.password.template 复制一份改名为jmxremote.password, 将最后的

 #monitorRole  QED

 

 #controlRole   R&D

的# 去掉,保存;

 

3.

a.最后将端口加入防火墙信任列表

b.重新启动tomcat

可以使用netstat -an | grep 9099命令查看端口是否正常启动。

至此,服务器端配置完毕。

4.使用windows客户机上的jconsole连接服务器端 进行监控。

 

   在本地磁盘下:H:\develop\Java7\jdk1.7.0_67\bin双击jconsole选择远程登录,输入用户名、密码,链接。

 

发现,文件没有授权;

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

注意:jmxremote.password和jmxremote.access文件只允许启动用户名对该文件拥有读写权限 ,我们服务用root启动 所以:

[root@localhost apache-tomcat-7.0.67]# cd /usr/java/jdk1.7.0_75/jre/lib/management/

[root@localhost management]# chmod 600 *

[root@localhost management]# ll

 

最后如果访问还是连接不上的话,就可能是主机ip没有配置好,这时运行一下hostname -i,如果显示的是127.0.0.1,这就需要配置一个hosts文件了 #vi /etc/hosts

 其实,我已经在服务器上再防火墙端口加入了我的端口了, 但是我显示一直链接失败,这个问题搞了大半天,才搞出来,就是直接将服务器上的防火墙关闭,一下就可以链接了!

 

 

 

猜你喜欢

转载自yjph83.iteye.com/blog/2292667