本文介绍了visualvm可以通过JMX自动连接到远程进程吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在远程计算机上运行了一个Java进程,该进程设置了一些mbeans。我还在该机器上以与Java进程相同的用户身份运行 jstatd 。 (可以通过编程方式或使用 -Dcom.sun.management.jmxremote ... 等设置mbeans,这似乎没有区别)。

I have a Java process running on a remote machine, and the process sets up some mbeans. I also have jstatd running on that machine as the same user as the Java process. (The mbeans can be set up programmatically or using -Dcom.sun.management.jmxremote... etc, this doesn't appear to make a difference).

VisualVM能够与该进程建立 jstatd 连接,它会自动发现,但这意味着我不要无法访问mbeans,或者访问CPU历史记录图表。或者我可以创建一个显式的JMX连接,它给了我通常的有用工具,但是我希望应用程序在启动时被分配一个随机的JMX端口,这个配置不能是静态的。

VisualVM is able to make a jstatd connection to the process, which it discovers automatically, but this means I don't get access to mbeans or, for example, the CPU history chart. Alternatively I can create an explicit JMX connection, which gives me the usual range of useful tools, but I want for the application to be assigned a random JMX port when it starts, this config can't be static.

有没有办法让VisualVM通过JMX自动连接到我的进程?这将要求它自动发现JMX端口,但我原以为 jstatd 可以做到这一点。有没有人知道visualvm的任何插件自动执行此操作?

Is there any way to get VisualVM to auto-connect to my process via JMX? This would require it to auto-discover the JMX ports, but I would have thought jstatd could do that. Does anyone know of any plugins for visualvm to automate this?

推荐答案

不幸的是没有办法将随机JMX端口分配给遥控器应用。您可以使用

Unfortunately there is no way to assign random JMX port to the remote application. You can start your remote application with

-Dcom.sun.management.jmxremote.port=<fixed port>
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false

并且VisualVM将能够通过(由jstatd提供)并自动打开与远程应用程序的JMX连接。因此,您需要将固定端口分配给远程应用程序。一旦你拥有它,一切都会正常工作,VisualVM将通过JMX自动连接到你的应用程序(实际上它将结合来自两者的数据和JMX)。

and VisualVM will be able to read this configuration via Jvmstat (provide by jstatd) and open JMX connection to your remote application automatically. So you need to assign fixed port(s) to your remote application(s). Once you have it, everything will work fine and VisualVM will automatically connect to your application via JMX (in fact it will combine data from both Jvmstat and JMX).

这篇关于visualvm可以通过JMX自动连接到远程进程吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 07:38