一、部署
编辑文件 /etc/default/grub
添加参数 ‘crashkernel=<Reserved_size_of_RAM>‘ 在 ‘GRUB_CMDLINE_LINUX‘ 后面。
GRUB_CMDLINE_LINUX="crashkernel=auto crashkernel=128M"
执行:
grub2-mkconfig -o /boot/grub2/grub.cfg
systemctl enable kdump.service
shutdown -r now
重启生效
/etc/kdump.conf
path /var/crash
core_collector makedumpfile -l --message-level 1 -d 31
default reboot
二、验收
执行:
systemctl is-active kdump.service
service kdump status
确认服务启动
三、测试
echo c > /proc/sysrq-trigger
。。。系统重启后。。。
ls -l /var/crash/
127.0.0.1-2016-04-07-22:07:03
成功会生成数据,例如:
[root@localhost 127.0.0.1-2016-04-07-22:07:03]# tail /var/crash/127.0.0.1-2016-04-07-22\:07\:03/vmcore-dmesg.txt
[ 77.675638] [<ffffffff813b9ed2>] __handle_sysrq+0xa2/0x170
[ 77.675668] [<ffffffff813ba3af>] write_sysrq_trigger+0x2f/0x40
[ 77.675701] [<ffffffff812492ad>] proc_reg_write+0x3d/0x80
[ 77.675829] [<ffffffff811de5cd>] vfs_write+0xbd/0x1e0
[ 77.675861] [<ffffffff811df06f>] SyS_write+0x7f/0xe0
[ 77.675911] [<ffffffff81645909>] system_call_fastpath+0x16/0x1b
[ 77.675928] Code: eb 9b 45 01 f4 45 39 65 34 75 e5 4c 89 ef e8 e2 f7 ff ff eb db 0f 1f 44 00 00 55 c7 05 80 e8 5b 00 01 00 00 00 48 89 e5 0f ae f8 <c6> 04 25 00 00 00 00 01 5d c3 0f 1f 44 00 00 55 31 c0 c7 05 fe
[ 77.676063] RIP [<ffffffff813b9716>] sysrq_handle_crash+0x16/0x20
[ 77.676088] RSP <ffff8800397a3e80>
[ 77.676099] CR2: 0000000000000000
四、调试
wget http://debuginfo.centos.org/7/x86_64/kernel-debug-debuginfo-3.10.0-327.el7.x86_64.rpm
wget http://debuginfo.centos.org/7/x86_64/kernel-debuginfo-common-x86_64-3.10.0-327.el7.x86_64.rpm
rpm -ivh kernel-debug-debuginfo-3.10.0-327.el7.x86_64.rpm kernel-debuginfo-common-x86_64-3.10.0-327.el7.x86_64.rpm
yum install crash
crash /usr/lib/debug/lib/modules/3.10.0-327.13.1.el7.x86_64/vmlinux /var/crash/127.0.0.1-2016-04-07-22\:07\:03/vmcore
crash>
开始调试
CentOS / RHEL 6 : How to configure kdump
kdump is an advanced crash dumping mechanism. When enabled, the system is booted from the context of another kernel. This second kernel reserves a small amount of memory, and its only purpose is to capture the core dump image in case the system crashes. Since being able to analyze the core dump helps significantly to determine the exact cause of the system failure, it is strongly recommended to have this feature enabled. This Note explains how to configure, test, and use the kdump service in CentOS/RHEL 6.
1. Install the kexec-tools package if not already installed
To use the kdump service, you must have the kexec-tools package installed.
# yum install kexec-tools
2. Configuring Memory Usage in GRUB
To configure the amount of memory that is reserved for the kdump kernel, modify file /boot/grub/grub.c