如何在JVM上激活JMX以使用jconsole进行访问?
当前回答
步骤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,然后单击连接按钮连接到远程应用程序。
您可以参考此链接以获得完整的应用程序。
其他回答
连同下面的命令行参数,
-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是掩码的,在主机文件中。
相关文件可在此找到:
http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html
用以下参数启动程序:
-Dcom.sun.management.jmxremote
-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
比如这样:
java -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 \
-jar Notepad.jar
-Dcom.sun.management.jmxremote.local。Only =false不一定是必需的 但是如果没有它,它就不能在Ubuntu上工作。误差是这样的 这样的:
01 Oct 2008 2:16:22 PM sun.rmi.transport. customer .TCPTransport$AcceptLoop executeAcceptLoop
WARNING: RMI TCP Accept-0: accept loop for ServerSocket[addr=0.0.0.0/0.0.0.0,port=0,localport=37278] throws
java.io.IOException: The server sockets created using the LocalRMIServerSocketFactory only accept connections from clients running on the host where the RMI remote objects have been exported.
at sun.management.jmxremote.LocalRMIServerSocketFactory$1.accept(LocalRMIServerSocketFactory.java:89)
at sun.rmi.transport. customer .TCPTransport$AcceptLoop.executeAcceptLoop(TCPTransport.java:387)
at sun.rmi.transport. customer .TCPTransport$AcceptLoop.run(TCPTransport.java:359)
at java.lang.Thread.run(Thread.java:636)
参见http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6754672
还要小心使用-Dcom.sun.management.jmxremote。验证= false, 任何人都可以访问,但是如果您只使用它来跟踪JVM 您的本地机器并不重要。
更新:
在某些情况下,我无法连接到服务器。如果我也设置了这个参数,这个问题就得到了解决:-Djava.rmi.server.hostname=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
首先,您需要检查java进程是否已经使用JMX参数运行。这样做:
ps -ef | grep java
检查您需要监视的java进程。如果你能看到jmx rmi参数Djmx.rmi.registry。Port =xxxx,然后在Java visualvm中使用这里提到的端口在JMX连接下远程连接它。
如果它没有通过jmx rmi端口运行,那么你需要使用以下提到的参数运行你的java进程:
-Djmx.rmi.registry.port=1234 -Djmx.rmi.port=1235 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
注意:端口号基于您的选择。
现在您可以将此端口用于jmx连接。这里是1234端口。
步骤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,然后单击连接按钮连接到远程应用程序。
您可以参考此链接以获得完整的应用程序。
推荐文章
- 如何格式化Joda-Time DateTime仅为mm/dd/yyyy?
- 如何在POM.xml中引用环境变量?
- 如何在android中复制一个文件?
- 将整数转换为字符串,以逗号表示千
- 接口方法的最终参数-有什么意义?
- Java中的@UniqueConstraint注释
- 如何在清洁模式下运行eclipse ?如果我们这样做会发生什么?
- 获取java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory异常
- Java中的正则表达式命名组
- c#和Java的主要区别是什么?
- 什么是NullPointerException,我如何修复它?
- 在Java中使用“final”修饰符
- 无法在Flutter上找到捆绑的Java版本
- 如何在Kotlin解析JSON ?
- 如何在新的材质主题中改变背面箭头的颜色?