我想使用jvisualvm的远程功能来查看远程JVM的实时统计信息。 我已经从我的Windows机器启动了jvisualvm,但我不知道如何配置远程连接。
On the remote machine (OS: Redhat Linux), tomcat is started with below jmx parameters:
-Dcom.sun.management.jmxremote"
-Dcom.sun.management.jmxremote.port=3030"
-Dcom.sun.management.jmxremote.authenticate=false"
-Dcom.sun.management.jmxremote.ssl=false"
netstat -lnp| grep 3030
tcp 0 0 0.0.0.0:3030 0.0.0.0:* LISTEN 30728/java
ssh连接对远程服务器开放,我在某个本地端口上隧道连接远程端口3030但是当我在jvisualvm中创建新的jmx连接(localhost:localport)时,我得到以下错误
使用服务无法连接到localhost:10000:jmx:rmi:/// jndi / rmi:// localhost:10000 / jmxrmi
有人可以帮我创建连接吗?
答案 0 :(得分:0)
首先,如果要进行远程连接,localhost连接没有意义。
您需要在远程计算机上启动jstatd。为此,在远程计算机的主目录中创建一个jstatd.all.policy文件,并添加以下行:
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
然后在远程计算机的命令行上输入' jstatd -J-Djava.security.policy = jstatd.all.policy -J-Djava.rmi.server.hostname = {Your ip address}'
在远程计算机上启动jstatd服务后,您基本上使用添加远程主机在jvisualVM UI上添加远程连接IP地址连接。
JvisualVM的Oracle文档可以在https://docs.oracle.com/javase/8/docs/technotes/guides/visualvm/applications_remote.html引用,但理解jstatd步骤真的很混乱。