Crash+Kdump 分析内核崩溃内存转储文件之环境搭建

时间:2022-05-01 16:51:17

虚拟机环境为centos 5.5 32bit

  1. kdump 服务和kexec-tools

    检查kexec-tools: rpm -qa|grep kexec-tools

    如果没有安装,yum install kexec-tools


    检查kdump:

    chkconfig kdump on

    /etc/init.d/kdump start

    如果没有安装系统时没装kdump, 会有如下提示:

    “/etc/kdump.conf

    Rebuilding /boot/initrd-2.6.18-194.el5kdump.img
    Warning!  Lack of dump target specification means default option is ignored!
    Starting kdump: ”

    ,然后,重新编译内核吧。

    编译内核:为了支持kdump 同时,也为以后可能会调试内核,参考http://www.ibm.com/developerworks/cn/linux/l-cn-dumpanalyse/ 支持kdump,参考http://blog.chinaunix.net/uid-20909886-id-4053827.html 支持内核调试,我的系统是centos 5.5 32位,内核版本2.6.18-194.el5,在ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Server/en/os/SRPMS/ 下载相同内核版本的发行版内核源码。编译内核比较顺利。centos 编译后的新内核,在grub.conf中会放在第一项,而此时default 值还是指向原来的内核项,修改之。

    值得一记的是,重启后,/etc/init.d/kdump start 失败,在内核后添加crashkernel=128M,重启

Memory for crash kernel (0x0 to 0x0) notwithin permissible range,和没加一样,当然kdump依然start失败;修改为crashkernel=128M@16M之后重启,Memory for crash kernel (0x0 to 0x0) notwithin permissible range提示消失,kdump起动成功。

2.  测试内核崩溃

    echo 1 > /proc/sys/kernel/sysrq

    echo c > /proc/sysrq-trigger

3. crash 

yum install crash 或者 下载crash源码包,编译安装。