JVisualVM 遠程鏈接 Docker 中的 JVM

 程序啓動時增加如下配置

-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 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章