无法将远程主机连接到 VisualVM

发布于 2024-12-12 02:51:31 字数 818 浏览 0 评论 0 原文

我是 Java 新手,在将远程主机连接到 JVisualVM 时遇到问题。

我已经在互联网上搜索并按照其中提到的所有步骤进行操作,但仍然无法解决该问题。我遵循的步骤是:

  1. 我首先在 $JAVA_HOME/bin 中创建一个 jstatd.all.policy 文件,从而在远程服务器上启动 jstatd。该文件包含: grant codebase "file:${java.home}/../lib/tools.jar" {permission java.security.AllPermission;};

  2. 我启动了Jstatd as jstatd -J-Djava.security.policy=jstatd.all.policy

  3. 我在远程主机上启动了 Java 应用程序:

    java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9000 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=错误的应用程序名称
    
  4. 然后,我在本地计算机上作为 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:

  1. 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;};

  2. I started the Jstatd as jstatd -J-Djava.security.policy=jstatd.all.policy

  3. 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
    
  4. 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

末蓝 2024-12-19 02:51:31

我在连接 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:

  • Try setting on your application:

    -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

  • 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

饮湿 2024-12-19 02:51:31

您需要使用指向服务器的外部 IP 或主机名的附加选项来启动 jstatd:

statd -J-Djava.security.policy=jstatd.all.policy -J-Djava.rmi.server.hostname=my_server_ip/hostname

答案基于: 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:

statd -J-Djava.security.policy=jstatd.all.policy -J-Djava.rmi.server.hostname=my_server_ip/hostname

Answer based on: https://java.net/projects/visualvm/lists/users/archive/2010-03/message/8

情魔剑神 2024-12-19 02:51:31

要连接到远程 VM,您必须使用特定选项启动该远程 VM

java
 -Dcom.sun.management.jmxremote
 -Dcom.sun.management.jmxremote.port=9000
 -Dcom.sun.management.jmxremote.ssl=false
 -Dcom.sun.management.jmxremote.authenticate=false
class

VM 启动后,转到 VisualVM 并执行以下操作:

  1. 文件 ->添加 JMX 连接
  2. 类型:yourHostName:9000 并单击“确定”
  3. 在左侧,您将看到添加的 JMX 连接,双击它即可!

有关Java监控和管理平台的更多详细信息,请访问这里

To connect to a remote VM you have to start that remote VM with specific options:

java
 -Dcom.sun.management.jmxremote
 -Dcom.sun.management.jmxremote.port=9000
 -Dcom.sun.management.jmxremote.ssl=false
 -Dcom.sun.management.jmxremote.authenticate=false
class

After the VM is started, go to your VisualVM and do the following:

  1. File -> Add JMX Connection
  2. Type: yourHostName:9000 and click OK
  3. On the left you will have the added JMX connection, double click on it and that's it!

More details on the Java Monitoring and Management Platform can be found here.

靑春怀旧 2024-12-19 02:51:31

以下是执行此操作的步骤:

  1. 以这种方式在远程主机中启动 ejstatd (在 ejstatd 文件夹中) ): mvn exec:java -Djava.rmi.server.hostname=; -Dexec.args="-pr 1099 -ph 1100 -pv 1101" (用于“jstatd”类型连接)(如果主机名仅指定 -Djava.rmi.server.hostname您的远程主机的主机名与您从本地网络看到的主机名不匹配)
  2. 使用这些附加 Java 参数启动您的 Java 应用程序:-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 的注释相同)
  3. 打开远程主机上的这 4 个端口并使它们可供本地计算机使用: 1099110011011102
  4. 启动 JVisualVM
    1. 右键单击“远程”> “添加远程主机...”并在“主机名”中输入您的远程主机名(如果您不使用端口1099,可以在“高级设置”中更改)
    2. 右键单击您刚刚创建的远程主机> “添加 JMX 连接...”并在“连接”输入中输入“:1102”,并选中“不需要 SSL 连接”
    3. 您的 Java 进程将出现两次:一次来自“jstatd”连接类型,另一次来自“JMX”连接类型。

免责声明:我是开源 ejstatd 工具的作者。

Here are the steps to do this:

  1. Launch an ejstatd in your remote host this way (in ejstatd folder): 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)
  2. Launch your Java application with those additional Java parameters: -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)
  3. Open those 4 ports on your remote host and make them available to your local machine: 1099, 1100, 1101 and 1102
  4. Launch JVisualVM
    1. Right-click on "Remote" > "Add Remote Host..." and enter your remote host name in "Host name" (if you don't use the port 1099, you can change this in the "Advanced Settings")
    2. Right-click on the remote host you've just created > "Add JMX Connection..." and enter "<remote_host_name>:1102" in "Connection" input, and check "Do not require SSL connection"
    3. Your Java process will appear twice: one from the "jstatd" connection type, and one from the "JMX" connection type.

Disclaimer: I'm the author of the open source ejstatd tool.

暖伴 2024-12-19 02:51:31

jstatd https://en.wikipedia.org/wiki/Nohup" rel="nofollow noreferrer">nohup 在需要监控的服务器上,并将 VisualVM 连接到 jstatd端口,执行以下步骤:

第 1 步:创建 start-jstatd.sh 并复制以下内容:

nohup jstatd -p 1099 -J-Djava.security.policy=<(echo 'grant codebase "file:${java.home}/../lib/tools.jar" {permission java.security.AllPermission;};') &

第 2 步: 授予可执行权限文件:

$ chmod a+rwx start-jstatd.sh

步骤 3: 启动 jstatd:

$ sh start-jstatd.sh

步骤 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:

nohup jstatd -p 1099 -J-Djava.security.policy=<(echo 'grant codebase "file:${java.home}/../lib/tools.jar" {permission java.security.AllPermission;};') &

Step 2: Give executable permission to the file:

$ chmod a+rwx start-jstatd.sh

Step 3: Start jstatd:

$ sh start-jstatd.sh

Step 4: Add Remote Host in VisualVM:

enter image description here

Step 5: Add JMX Connection to the Remote Host, as shown in the below image and Click OK button:
enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文