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


当前回答

在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)

其他回答

在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)

使用以下命令行参数运行java应用程序:

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

使用-Dcom.sun.management.jmxremote非常重要。如果不想在JMX主机上设置数字证书,则使用Ssl =false参数。

如果在IP地址为192.168.0.1的机器上启动应用程序,则打开jconsole,在Remote Process字段中输入192.168.0.1:8855,然后单击Connect。

以下选项适合我:

-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

我使用的是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

步骤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,然后单击连接按钮连接到远程应用程序。

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