IBM JDK在linux下生成HeapDump日志方法

阅读更多

        最近服务器老是宕机,同时会生成.phd,javacore....txt等日志文件。说明此时服务器已经发生OOM或者由于其他原因导致了服务器宕机。每次必须等到服务器宕机时才能获取这些日志,服务器响应慢时,怎样手工生成这些日志分析呢?

 

        通过kill -3 进程号能生成javacore....txt日志,但是没法生成.phd文件。而.phd文件是JVM内存映射文件,获取它才能分析此时JVM内存的情况,进而分析出服务器宕机的原因。

 

        对于IBM JDK需要做以下设置:

        1.设置JVM参数:

           -XX:+HeapDumpOnOutOfMemoryError -XX:+HeapDumpOnCtrlBreak

        2.设置操作系统环境变量:

           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...

 

参考知识:
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

 

你可能感兴趣的:(IBM,JDK,dump,linux)