如何在JVM上激活JMX以使用jconsole进行访问?


当前回答

以下选项适合我:

-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.port=9010
-Dcom.sun.management.jmxremote.rmi.port=9010
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname={host name}

并且记得在服务器上打开9010端口

sudo ufw allow 9010/udp
sudo ufw allow 9010/tcp
sudo ufw reload

其他回答

在Linux上,我使用以下参数:

-Djavax.management.builder.initial= 
-Dcom.sun.management.jmxremote 
-Dcom.sun.management.jmxremote.port=9010 
-Dcom.sun.management.jmxremote.local.only=false
-Dcom.sun.management.jmxremote.authenticate=false 
-Dcom.sun.management.jmxremote.ssl=false

我还编辑了/etc/hosts,以便主机名解析为主机地址(192.168.0.x),而不是环回地址(127.0.0.1)

我使用的是WAS ND 7.0

我的JVM需要在JConsole中监视以下所有参数

    -Djavax.management.builder.initial= 
    -Dcom.sun.management.jmxremote 
    -Dcom.sun.management.jmxremote.port=8855 
    -Dcom.sun.management.jmxremote.authenticate=false 
    -Dcom.sun.management.jmxremote.ssl=false

使用远程进程选项运行本地进程JCONSOLE

为了在本地运行,这对我来说是可行的

我在vm args -中添加了这个

-Dcom.sun.management.jmxremote=true
-Dcom.sun.management.jmxremote.port=6001
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Djava.rmi.server.hostname=localhost
-Dcom.sun.management.jmxremote.rmi.port=6001

我通过Intellij终端打开JConsole 它给我显示了本地所有的PID值 所以我选择了远程进程,并使用主机- localhost:6001登录 用户名和密码为空 然后点击连接


确保端口6001上没有其他进程正在运行。您也可以使用其他端口。

连同下面的命令行参数,

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

在linux服务器上,有时imx连接不成功。这是因为,在云Linux主机中,在/etc/hosts中使主机名解析为主机地址。

修复它的最好方法是,从网络中的其他机器ping特定的linux服务器,并使用该主机IP地址

-Djava.rmi.server.hostname=IP address that obtained when you ping that linux server.

但是永远不要依赖于你从linux服务器上使用ifconfig.me获得的ipaddress。你得到的IP是掩码的,在主机文件中。

步骤1:使用以下参数运行应用程序。

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

上述参数将应用程序绑定到端口9999。

步骤2:在命令提示符或终端中执行命令jconsole来启动jconsole。

选择“远程进程:”并输入url为{IP_Address}:9999,然后单击连接按钮连接到远程应用程序。

您可以参考此链接以获得完整的应用程序。