java 调试 VisualVM 远程连接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10543882/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 01:29:54  来源:igfitidea点击:

Debugging VisualVM remote connection

javatomcatjmxvisualvm

提问by jsd

I am running Tomcat 6 on a Linux server in Amazon's cloud. I am trying to connect to it with VisualVM from my Mac at my office. I have allowed opened up all TCP ports between my desktop and the server, but I am unable to get VisualVM to do anything.

我在亚马逊云中的 Linux 服务器上运行 Tomcat 6。我正在尝试从我办公室的 Mac 上使用 VisualVM 连接到它。我已经允许打开我的桌面和服务器之间的所有 TCP 端口,但是我无法让 VisualVM 做任何事情。

On the linux box, I have started Tomcat with:

在 linux 机器上,我已经启动了 Tomcat:

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

On my Mac, I launch VisualVM and choose File -> New JMX Connection...

在我的 Mac 上,我启动 VisualVM 并选择 File -> New JMX Connection...

I enter amazonhostname.com:9191 in the box. It says "Adding amazonhostname.com:9191..." and sits there for several minutes before timing out.

我在框中输入 amazonhostname.com:9191。它说“正在添加 amazonhostname.com:9191...”并在超时前在那里停留了几分钟。

From my Mac, I can "telnet amazonhostname.com 9191" just fine, and I tried some other random ports, and they all worked. I'm pretty convinced it's not a firewall issue, unless I need to open UDP or ICMP or something like that. (Really??)

在我的 Mac 上,我可以“telnet amazonhostname.com 9191”就好了,我尝试了其他一些随机端口,它们都有效。我非常确信这不是防火墙问题,除非我需要打开 UDP 或 ICMP 或类似的东西。(真的??)

There is nothing in catalina.log on the server, or the system console on my Mac, related to jmx. netstat on the server shows 9191 and some other ports open on all interfaces.

服务器上的 catalina.log 或 Mac 上的系统控制台中没有任何与 jmx 相关的内容。服务器上的 netstat 显示 9191 和其他一些端口在所有接口上打开。

There is no jstatd on the remote server. Is that a pre-requisite for JMX? (I am totally new to Java and I'm not even sure what those things mean, but I saw it on a blog post somewhere. I'm grasping at straws now.)

远程服务器上没有 jstatd。这是 JMX 的先决条件吗?(我对 Java 完全陌生,我什至不确定这些东西是什么意思,但我在某处的博客文章中看到了它。我现在正在抓紧稻草。)

回答by Greg Kopff

Set the hostname property before the VM starts:

在 VM 启动之前设置主机名属性:

java -Dcom.sun.management.jmxremote \
     -Dcom.sun.management.jmxremote.port=9191 \
     -Dcom.sun.management.jmxremote.authenticate=false \
     -Dcom.sun.management.jmxremote.ssl=false \
     -Djava.rmi.server.hostname=the.public.ip \
     -jar program.jar

Add the relevant rules to your security group.

将相关规则添加到您的安全组。

回答by Francis Vinluan

What worked well for me in RHEL7 environment is implement is to implement JmxRemoteLifecycleListener on Tomcat. Using the example provided by the documentation, I have also opened up ports 10001 and 10002 on the firewall. JMX Remote Lifecycle Listener

在 RHEL7 环境中对我来说效果很好的是实现是在 Tomcat 上实现 JmxRemoteLifecycleListener。使用文档提供的示例,我还打开了防火墙上的10001和10002端口。 JMX 远程生命周期侦听器