程序启动时增加如下配置
-Djava.rmi.server.hostname=ip
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.rmi.port=7098
-Dcom.sun.management.jmxremote.port=7099
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/app/gc.hprof
jar 程序启动命令
java
-Djava.rmi.server.hostname=ip
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.rmi.port=7098
-Dcom.sun.management.jmxremote.port=7099
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/app/gc.hprof
-jar
xxx.jar
7098 为 jstatd 链接
7099 为 jmx 链接
docker 中启动也需要带入JVM参数,并且将 7098,7099端口映射到外部即可
内存泄露设置错误记录文件位置及文件名
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/app/gc.hprof
本文详细介绍了如何通过配置JVM参数来启用JMX远程监控,包括设置主机名、端口、认证和SSL等。同时,展示了如何配置程序在内存溢出时自动创建堆转储文件,以及指定其保存路径。
3321

被折叠的 条评论
为什么被折叠?



