Visual GC uses the jvmstat technology to gather data from the monitored
application. This means that the monitored application must either run locally
or there must be a jstatd agent up and running on the remote system. For remote
applications added using the JMX connection you will only see the "Not supported
for this JVM" message - there‘s no jvmstat
available.
监控远程Java进程的JVM有两个条件:
1、应用运行在本地环境。
2、远程系统启动了jstatd
agent
VisualVM监控远程JVM是通过RMI服务器来实现的,因此需要在被监控的远程服务器上启动RMI服务
需要在被监控的服务器上面,通过jstatd来启动RMI服务。
在/usr/local/java/bin/目录下新建个文件jstatd.all.policy
文件内容如下:
# vi
jstatd.all.policy
grant codebase
"file:${java.home}/../lib/tools.jar" {
permission
java.security.AllPermission;
};
然后通过执行如下的命令启动被监控服务器上的RMI服务:
# jstatd
-J-Djava.security.policy=jstatd.all.policy
&
如果没有添加jstatd.all.policy会报错信息:
Could not
create remote object
access denied (java.util.PropertyPermission
java.rmi.server.ignoreSubClasses
write)
java.security.AccessControlException: access denied
(java.util.PropertyPermission java.rmi.server.ignoreSubClasses
write)
at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
at
java.security.AccessController.checkPermission(AccessController.java:546)
at
java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at
java.lang.System.setProperty(System.java:725)
at sun.tools.jstatd.Jstatd.main(Jstatd.java:122)
默认端口1099,可设置端口为2020
./jstatd
-J-Djava.security.policy=jstatd.all.policy -p 2020
&
jstatd会跟本地的一个ip地址绑定(hostname
-i显示的ip地址),可以启动时指定绑定IP:
# jstatd
-J-Djava.rmi.server.hostname=192.168.1.115
-J-Djava.security.policy=jstatd.all.policy -p 11099
&
如果绑定的hostname不对可以修改:
# hostname
newhostname
jvisualvm not suppout this jvm
原文:http://www.cnblogs.com/aiguang/p/3554613.html