如何找到默认的JMX端口号? [英] How to find the default JMX port number?

查看:4076
本文介绍了如何找到默认的JMX端口号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在远程Windows XP上的Java 6 VM上运行Java应用程序,我可以在其上运行jvisualvm.exe以自动连接到正在运行的应用程序。

I am running a Java application on Java 6 VM on a remote Windows XP, on which I can run jvisualvm.exe to connect to the running application automatically.

现在我需要从本地计算机连接该应用程序,但我不知道远程计算机的JMX端口号。我在哪里可以找到它?或者,我是否必须使用某些VM参数重新启动该应用程序以指定端口号?

Now I need to connect that application from my local computer, but I don't know the JMX port number of the remote computer. Where can I find it? Or, must I restart that application with some VM parameters to specify the port number?

阅读问题后如何在服务器中找到JMX端口,我在远程计算机上执行命令

After reading the question How to find the JMX port in a server, I executed the command on the remote computer

netstat -apn

但什么都没有。

推荐答案

默认情况下,除非您从此页面指定参数,否则JMX不会在端口上发布:如何激活JMX ......

By default JMX does not publish on a port unless you specify the arguments from this page: How to activate JMX...

-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9010
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false

如果您正在运行,您应该能够访问任何这些系统rties,看看他们是否已设置:

If you are running you should be able to access any of those system properties to see if they have been set:

if (System.getProperty("com.sun.management.jmxremote") == null) {
    System.out.println("JMX remote is disabled");
} else [
    String portString = System.getProperty("com.sun.management.jmxremote.port");
    if (portString != null) {
        System.out.println("JMX running on port "
            + Integer.parseInt(portString));
    }
}

根据服务器的连接方式,您可能还需要必须指定以下参数。作为初始JMX连接的一部分,jconsole连接到RMI端口以确定运行JMX服务器的端口。当您最初启动启用JMX的应用程序时,它会查找自己的主机名,以确定在该初始RMI事务中返回的地址。如果您的主机名不在 / etc / hosts 中,或者如果它被设置为错误的接口地址,那么您可以使用以下内容覆盖它:

Depending on how the server is connected, you might also have to specify the following parameter. As part of the initial JMX connection, jconsole connects up to the RMI port to determine which port the JMX server is running on. When you initially start up a JMX enabled application, it looks its own hostname to determine what address to return in that initial RMI transaction. If your hostname is not in /etc/hosts or if it is set to an incorrect interface address then you can override it with the following:

-Djava.rmi.server.hostname=<IP address>

顺便说一下,我的 SimpleJMX包允许您定义 JMX服务器 RMI端口或将它们设置为同一端口。使用 com.sun.management.jmxremote.port 定义的上述端口实际上是RMI端口。这告诉客户端JMX服务器正在运行什么端口。

As an aside, my SimpleJMX package allows you to define both the JMX server and the RMI port or set them both to the same port. The above port defined with com.sun.management.jmxremote.port is actually the RMI port. This tells the client what port the JMX server is running on.

这篇关于如何找到默认的JMX端口号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆