简体   繁体   English

如何在 ubuntu 中将 JMC(Java Mission Control)连接到远程 JVM?

[英]How to connect JMC (Java Mission Control) to remote JVM in ubuntu?

I am able to connect to JMC to the JVM while on the same system.我能够在同一系统上将 JMC 连接到 JVM。 However, I want to monitor a remote server.但是,我想监视远程服务器。 How do I connect my local JMC to my remote JVM?如何将本地 JMC 连接到远程 JVM?

It's all described in the documentation: 这些都在文档中描述:
1. Click Help->Java Mission Control Help. 1.单击帮助 - > Java任务控制帮助。
2. Check the JVM browser help. 2.检查JVM浏览器帮助。

For more detailed information, check out: 有关更多详细信息,请查看:
http://docs.oracle.com/javase/7/docs/technotes/guides/management/agent.html http://docs.oracle.com/javase/7/docs/technotes/guides/management/agent.html

First you need to enable the external JMX agent on the server. 首先,您需要在服务器上启用外部JMX代理。 You do this by adding the relevant com.sun.management.jmxremote to the command line flags for the server JVM you wish to connect to. 您可以通过将相关的com.sun.management.jmxremote添加到要连接的服务器JVM的命令行标志来执行此操作。 Here is a simple example of a set of system properties that can be used. 以下是可以使用的一组系统属性的简单示例。 They disable security and authentication, so NEVER use it like this in production: 它们会禁用安全性和身份验证,因此不要在生产中使用它:

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

Next you create a custom connection in JMC. 接下来,在JMC中创建自定义连接。 You do this by clicking the "Create custom connection" button in the JVM browser: 您可以通过单击JVM浏览器中的“创建自定义连接”按钮来执行此操作: 创建自定义连接按钮的位置

In the upcoming dialog you simply enter the host and port. 在即将出现的对话框中,您只需输入主机和端口即可。

If you run into trouble, first check the last chapter of the documentation included with JMC (Frequently Asked Questions): 如果遇到麻烦,请先查看JMC(常见问题)附带的文档的最后一章: 在哪里可以找到帮助

If that does not help, the JMC Forum has a more extensive FAQ: https://community.oracle.com/message/11182417#11182417 . 如果这没有帮助,JMC论坛有一个更广泛的常见问题解答: https//community.oracle.com/message/11182417#11182417

My environment is jboss 7.1 in Linux, was trying to connect JMC to my jboss instance, initially I got problems with connection refused - after a day and half of digging, remote JMC works for me now, with the following configs in standalone.conf: 我的环境是Linux中的jboss 7.1,试图将JMC连接到我的jboss实例,最初我遇到连接被拒绝的问题 - 经过一天半的挖掘,远程JMC现在为我工作,在standalone.conf中使用以下配置:

JBOSS_MODULES_SYSTEM_PKGS="org.jboss.byteman,org.jboss.logmanager"

JAVA_OPTS="$JAVA_OPTS -Djboss.modules.system.pkgs=$JBOSS_MODULES_SYSTEM_PKGS"


JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager"

JAVA_OPTS="$JAVA_OPTS -Xbootclasspath/p:/apps/jboss-as-7.1.1.Final/modules/org/jboss/logmanager/main/jboss-logmanager-1.2.2.GA.jar"
JAVA_OPTS="$JAVA_OPTS -Xbootclasspath/p:/apps/jboss-as-7.1.1.Final/modules/org/jboss/logmanager/log4j/main/jboss-logmanager-log4j-1.0.0.GA.jar"
JAVA_OPTS="$JAVA_OPTS -Xbootclasspath/p:/apps/jboss-as-7.1.1.Final/modules/org/apache/log4j/main/log4j-1.2.16.jar"

JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote=true"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.port=7091"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.rmi.port=7091"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote.ssl=false"

JAVA_OPTS="$JAVA_OPTS -XX:+UnlockCommercialFeatures"
JAVA_OPTS="$JAVA_OPTS -XX:+FlightRecorder"

I was able to see a JVM within VirtualBox (Host: Win10, Guest: Ubuntu 20.04) after running the target JVM with following flags:使用以下标志运行目标 JVM 后,我能够在 VirtualBox(主机:Win10,来宾:Ubuntu 20.04)中看到 JVM:

java -XX:+FlightRecorder \
-Dcom.sun.management.jmxremote.port=1101 \
-Dcom.sun.management.jmxremote \
-Dcom.sun.management.jmxremote.authenticate=false \
-Dcom.sun.management.jmxremote.ssl=false \
MyApp

In the server {Ubuntu} Edit the /etc/hosts file 在服务器{Ubuntu}中编辑/etc/hosts文件

127.0.1.1       server-name

Replace above line with this line 用这一行替换上面的行

<system-ip>     server-name

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM