JVisualVM 远程链接 Docker 中的 JVM

本文详细介绍了如何通过配置JVM参数来启用JMX远程监控,包括设置主机名、端口、认证和SSL等。同时,展示了如何配置程序在内存溢出时自动创建堆转储文件,以及指定其保存路径。

 程序启动时增加如下配置

-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 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值