如何在我的 JVM 上激活 JMX 以使用 jconsole 进行访问? [英] How to activate JMX on my JVM for access with jconsole?

查看:17
本文介绍了如何在我的 JVM 上激活 JMX 以使用 jconsole 进行访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How to activate JMX on a JVM for access with jconsole?

推荐答案

相关文档可以在这里找到:

The relevant documentation can be found here:

http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html

使用以下参数启动您的程序:

Start your program with following parameters:

-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 上不起作用.错误将类似于这个:

-Dcom.sun.management.jmxremote.local.only=false is not necessarily required but without it, it doesn't work on Ubuntu. The error would be something like this:

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.authenticate=false使任何人都可以访问,但如果您只使用它来跟踪 JVM你的本地机器没关系.

Also be careful with -Dcom.sun.management.jmxremote.authenticate=false which makes access available for anyone, but if you only use it to track the JVM on your local machine it doesn't matter.

更新:

在某些情况下,我无法访问服务器.如果我也设置此参数,则此问题已得到修复:-Djava.rmi.server.hostname=127.0.0.1

In some cases I was not able to reach the server. This was then fixed if I set this parameter as well: -Djava.rmi.server.hostname=127.0.0.1

这篇关于如何在我的 JVM 上激活 JMX 以使用 jconsole 进行访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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