如何在JVM上激活JMX以使用jconsole进行访问?
当前回答
使用远程进程选项运行本地进程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上没有其他进程正在运行。您也可以使用其他端口。
其他回答
在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)
相关文件可在此找到:
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
我有这个确切的问题,并创建了一个GitHub项目来测试和找出正确的设置。
它包含一个工作Dockerfile和支持脚本,以及一个简单的docker-compose。Yml快速测试。
步骤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 ?
- 如何在新的材质主题中改变背面箭头的颜色?