IBM JDK在linux下產生HeapDump日誌方法 最近伺服器老是宕機,同時會產生.phd,javacore....txt等記錄檔。說明此時伺服器已經發生OOM或者由於其他原因導致了伺服器宕機。每次必須等到伺服器宕機時才能擷取這些日誌,伺服器響應慢時,怎樣手工產生這些日誌分析呢? 通過kill -3 進程號能產生javacore....txt日誌,但是沒法產生.phd檔案。而.phd檔案是JVM記憶體對應檔,擷取它才能分析此時JVM記憶體的情況,進而分析出伺服器宕機的原因。 www.2cto.com 對於IBM JDK需要做以下設定:1.設定JVM參數: -XX:+HeapDumpOnOutOfMemoryError -XX:+HeapDumpOnCtrlBreak2.設定作業系統內容變數: export IBM_HEAP_DUMP=true export IBM_HEAPDUMP=true export IBM_HEAPDUMP_OUTOFMEMORY=true export IBM_JAVADUMP_OUTOFMEMORY=true export IBM_JAVACORE_OUTOFMEMORY=true重啟伺服器。如果這樣仍然解決不了問題,則需要在伺服器啟動指令碼添加一行: #!/bin/ksh #... set -m some variable... www.2cto.com 參考知識:Issue: When WebLogic server (any version) is started in the background on a UNIX system, "kill -3" will not produce a thread dump as it does when the JVM is run in the foreground. This causes problems for support and debugging since some installations run WebLogic under nohup in the background so that the process is no longer associated with a terminal (so the originating terminal can logoff). Resolution: Modify the first line of the startWebLogic.sh shell script (or whatever name you are using) to cause the startup script to be run by the Korn shell (ksh), and set monitor mode in the shell script.This is done by changing the first line of the script (the one containing "#!/bin/sh" to "#!/bin/bin/ksh" -- if that is where ksh is installed on your machine. - then add a line: "set -m" as the first, non-comment, executable line of the shell, e.g., right before the JAVA_HOME variable is set. This causes all processes executed by the shell script to be leaders of their own process groups, allowing them to respond to the "kill -3" signal. The Korn shell must be used since the Bourne shell does not provide the "-m" setting.HP JDK產生Heapdump檔案需要在在環境變數上,加上export _JAVA_HEAPDUMP=1