Jconsole远程连接

http://download.oracle.com/javase/6/docs/technotes/guides/management/agent.html#gdeum

  根据oracle网站上的文档,本地使用jconsole没有问题。但当我从windows连接到linux时(centos5.4)时,老是连接不上)。原因是Linux上JVM给jconsole的RMI配置文件不对,

jvm使用了hostname -i的IP地址,我的/etc/hosts上127.0.0.1,所以远程老是连接不上。

   只要在java启动参数中加入 -Djava.rmi.server.hostname=192.168.0.10  显示说明JVM返回给jconsole的IP地址即可。

挡在java启动参数中加入 -Dcom.sun.management.jmxremote.port=6666  时,jvm回去读取  JRE_HOME/lib/management/jmxremote.password 和  JRE_HOME/lib/management/jmxremote.access文件。其中jmxremote.password 说明远程访问的用户名和密码, jmxremote.access说明用户的访问权限,有readonly和readwrite选项。 jmxremote.password 可以有jmxremote.password.template生成,同时要注意修改jmxremote.password的访问权限为用户只读,组和others无权限,  chmod 0400 ./jmxremote.password。

否则会出现Error: Password file read access must be restricted: /root/jdk1.6.0_26/jre/lib/management/jmxremote.password

  一下两个选项分别禁止ssl验证和无用户名密码访问

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

猜你喜欢

转载自republicw.iteye.com/blog/1987674
今日推荐