RHEL5开始,kexec-tools是默认安装的
如果需要调试kdump生成的vmcore文件,需要手动安装kernel-debuginfo包。
1. 安装kernel-debuginfo和kernel-debuginfo-common
地址: http://debuginfo.centos.org/6/x86_64/
[root@Dwan ~] uname -a #确认内核版本,安装和内核版本一致的debug
Linux Tencent 2.6.32-754.11.1.el6.x86_64
[root@Dwan ~] wget http://debuginfo.centos.org/6/x86_64/kernel-debuginfo-2.6.32-754.11.1.el6.x86_64.rpm
[root@Dwan ~] wget http://debuginfo.centos.org/6/x86_64/kernel-debuginfo-common-x86_64-2.6.32-754.11.1.el6.x86_64.rpm
[root@Dwan ~] rpm -ivh kernel-debuginfo-2.6.32-754.11.1.el6.x86_64.rpm
[root@Dwan ~] rpm -ivh kernel-debuginfo-common-x86_64-2.6.32-754.11.1.el6.x86_64.rpm6_64.rpm
2. 安装crash
[root@Dwan ~] rpm -qa | grep kexec-tools #确认是否安装kexec工具
kexec-tools-2.0.15-21.el7.x86_64
[root@Dwan ~] yum install crash #安装crash
(1) 预留内存
可以修改内核引导参数,为启动捕获内核预留指定内存。
在/etc/grub.conf (一般为/boot/grub/grub.conf的软链接)中:
crashkernel=Y@X,Y是为kdump捕获内核保留的内存,X是保留部分内存的起始位置。
默认为crashkernel=auto,可自行设定如crashkernel=256M
[root@Dwan ~] vim /etc/grub.conf
crashkernel=256M
(2) 配置文件
配置文件为/etc/kdump.conf,以下是几个常用配置:
[root@Dwan ~] vim /etc/kdump.conf
path /var/crash #默认的vmcore存放目录为/var/crash/%HOST-%DATE/,包括两个文件:vmcore和vmcore-dmesg.txt
ssh root@119.29.175.150 #自动将dump文件拷贝到目的主机
default <reboot | halt | poweroff | shell | mount_root_run_init>
#转储失败所需的操作
(3) 启动服务
[root@Dwan ~] chkconfig kdump on #开机启动
[root@Dwan ~] service kdump status #start、stop、restart等
Kdump is operational #正在运行
(4) 功能验证
[root@Dwan ~] echo c > /proc/sysrq-trigger #模拟机内内核奔溃
机器会发生重启,重新连接进入查看文件
[root@Dwan ~] ls /var/crash/127.0.0.1-2019-04-13-00\:25\:41/
vmcore vmcore-dmesg.txt