Centos7 内核调试

 

一、部署

编辑文件 /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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值