我是 Java 新手,在将远程主机连接到 JVisualVM
时遇到问题。
我已经在互联网上搜索并按照其中提到的所有步骤进行操作,但仍然无法解决该问题。我遵循的步骤是:
-
我首先在 $JAVA_HOME/bin
中创建一个 jstatd.all.policy
文件,从而在远程服务器上启动 jstatd。该文件包含: grant codebase "file:${java.home}/../lib/tools.jar" {permission java.security.AllPermission;};
-
我启动了Jstatd
as jstatd -J-Djava.security.policy=jstatd.all.policy
-
我在远程主机上启动了 Java 应用程序:
java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9000 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=错误的应用程序名称
-
然后,我在本地计算机上作为 JVisualVM
的实例启动,当我添加远程主机时,它已连接,但我无法看到任何 Java 进程。
谁能帮我解决这个问题吗?
谢谢。
I am new to Java and I'm facing a problem in connecting a Remote Host to the JVisualVM
.
I've searched the Internet and followed all the steps mentioned there but still am not able to resolve the issue. The steps I followed are:
-
I started the jstatd on the remote server by first creating a jstatd.all.policy
file in the $JAVA_HOME/bin
. The file contained: grant codebase "file:${java.home}/../lib/tools.jar" { permission java.security.AllPermission;};
-
I started the Jstatd
as jstatd -J-Djava.security.policy=jstatd.all.policy
-
I started the Java application on the remote host as :
java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9000 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false application_name
-
I then started as instance of the JVisualVM
on my local machine and as I added the remote host, it got connected but i wasn't able to see any of the Java processes.
Can anyone please help me with this.
Thanks.
发布评论
评论(5)
我在连接 Glassfish 应用服务器时遇到了类似的问题。查看对我有用的解决方案,因为它们对您来说可能是相同的:
<块引用>
-Djava.rmi.server.hostname=*Remote_Server_External_IP_Address*
The mentioned IP address should be server external IP (may sound silly but it worked for me). The main problem in my case was JMX pointing to the localhost and looping. In config files the exact IP address should be set to the remote host. I described it as 'Problem 2' In my blog: handling connection problems
如果防火墙阻止是一个问题,那么我建议尝试使用 SSH 隧道的 XMing(设置很简单)。如果您在设置时遇到问题,这里是说明:
通过 Xming 远程使用 VisualVM(我的博客)
使用 XMing 的最大优点是,当启用 SSH 时它几乎总是可以工作。您只需将 VisualVM 文件放置在远程主机上并从命令行运行它。 XWindow 将在您的本地计算机上显示 VisualVM 窗口。
有可能是 VisualVM 问题 - 尝试使用其他工具来验证问题所在。我推荐JConsole。它的工作原理与 VisualVM 类似,我还在我的博客
I encountered similar problems when connecting to Glassfish application server. See solutions that worked for me as they can be same for You:
The mentioned IP address should be server external IP (may sound silly but it worked for me). The main problem in my case was JMX pointing to the localhost and looping. In config files the exact IP address should be set to the remote host. I described it as 'Problem 2' In my blog: handling connection problems
If Firewall block is an issue then I recommend trying XMing with SSH tunnel (which is simple to set). Here is instruction, if You encounter problems setting it:
Remote use of VisualVM with Xming (my blog)
Biggest advantage of using XMing is that it will work almost always when SSH is enabled. You just have to place VisualVM files on the remote host and run it from command line. XWindow will show VisualVM Window on Your local computer.
There is a chance that it is VisualVM issue - try using some other tool just to verify what is wrong. I recommend JConsole. It works similar to VisualVM and I also described details on my blog
您需要使用指向服务器的外部 IP 或主机名的附加选项来启动 jstatd:
答案基于: https://java.net/projects/visualvm/lists/users/archive/2010-03/message/8
You need to start jstatd with the additional option that points to the server's external IP or hostname:
Answer based on: https://java.net/projects/visualvm/lists/users/archive/2010-03/message/8
要连接到远程 VM,您必须使用特定选项启动该远程 VM:
VM 启动后,转到 VisualVM 并执行以下操作:
有关Java监控和管理平台的更多详细信息,请访问这里。
To connect to a remote VM you have to start that remote VM with specific options:
After the VM is started, go to your VisualVM and do the following:
More details on the Java Monitoring and Management Platform can be found here.
以下是执行此操作的步骤:
-Djava.rmi.server.hostname
您的远程主机的主机名与您从本地网络看到的主机名不匹配)-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=1102 -Dcom.sun.management.jmxremote.rmi.port=1102 -Djava.rmi.server.hostname=
(用于“JMX”类型连接)(与上一点-Djava.rmi.server.hostname
的注释相同)1099
、1100
、1101
和1102
1099
,可以在“高级设置”中更改):1102
”,并选中“不需要 SSL 连接”免责声明:我是开源 ejstatd 工具的作者。
Here are the steps to do this:
mvn exec:java -Djava.rmi.server.hostname=<remote_host_name> -Dexec.args="-pr 1099 -ph 1100 -pv 1101"
(used for "jstatd" type connection) (only specify-Djava.rmi.server.hostname
if the hostname of your remote host does not match with the one you are seeing from your local network)-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=1102 -Dcom.sun.management.jmxremote.rmi.port=1102 -Djava.rmi.server.hostname=<remote_host_name>
(used for "JMX" type connection) (same remark as the previous point for-Djava.rmi.server.hostname
)1099
,1100
,1101
and1102
1099
, you can change this in the "Advanced Settings")<remote_host_name>:1102
" in "Connection" input, and check "Do not require SSL connection"Disclaimer: I'm the author of the open source ejstatd tool.
在 jstatd https://en.wikipedia.org/wiki/Nohup" rel="nofollow noreferrer">nohup 在需要监控的服务器上,并将
VisualVM
连接到 jstatd端口,执行以下步骤:第 1 步:创建
start-jstatd.sh
并复制以下内容:第 2 步: 授予可执行权限文件:
步骤 3: 启动 jstatd:
步骤 4: 在
VisualVM
中添加远程主机:第 5 步: 添加JMX 连接到远程主机,如下图所示,然后单击“确定”按钮:
Start jstatd in nohup on the server which needs to be monitored and connect
VisualVM
to the jstatd port, following below steps:Step 1 : Create
start-jstatd.sh
and copy the below content:Step 2: Give executable permission to the file:
Step 3: Start jstatd:
Step 4: Add Remote Host in
VisualVM
:Step 5: Add JMX Connection to the Remote Host, as shown in the below image and Click OK button: