我正在使用以下命令在安装了 java 1.8 的 RHEL 服务器上启动 Java SpringBoot 应用程序:-
java -jar App.jar --spring.profiles.active=dev -Xms96m -Xmx128m -XX:+HeapDumpOnOutOfMemoryError -XX:+UseG1GC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:loggc.log
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=5901
-Dcom.sun.management.jmxremote.rmi.port=5901
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.local.only=false
-Djava.rmi.server.hostname=localhost
当 jar 成功启动时,一个 PID 已被分配,我想监控该 PID 以了解堆利用率。因此,我试图通过在 Windows 环境中使用 JConsole 并使用 putty 端口转发将 Linux 上的 JMX 端口与 Windows 上的端口绑定(bind)来实现这一点。
但是由于 JRMP 连接失败,我无法成功连接。
有朝一日可以让我深入了解我可能做错了什么,或者是否有更好的方法来分析 Linux 环境中的堆利用率。
我尝试通过 jconsole 5901 访问它,但它显示远程端点上有非 JRMP 服务器。
最佳答案
参数的顺序是错误的。这些参数在您的 main 方法中作为 args 可用,但 Java 运行时并不关心它们。
java -h
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
如果顺序正确,Java 运行时将获取参数而不是您的应用程序。
java -Xms96m -Xmx128m -XX:+HeapDumpOnOutOfMemoryError -XX:+UseG1GC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:loggc.log
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=5901
-Dcom.sun.management.jmxremote.rmi.port=5901
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.local.only=false
-Djava.rmi.server.hostname=localhost
-jar App.jar --spring.profiles.active=dev
关于java - 将 Windows 上的 JConsole 与 Linux 上的远程 Java Springboot 应用程序连接时连接失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54340632/