Linux内核开启kdump

2023-12-29 13:50:54

# ulimit -c
?输出 0 表示没有开启
?输出 unlimited 表示开启

//将这个加到 /etc/profile ?或者 /etc/rc.d/rc.local 中
# ulimit -c unlimited

//修改启动项
[root@localhost ~]# cat /etc/default/grub?
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=0
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=512M rd.lvm.lv=zstack/root rd.lvm.lv=zstack/swap rhgb quiet intel_iommu=on modprobe.blacklist=snd_hda_intel,amd76x_edac,vga16fb,nouveau,rivafb,nvidiafb,rivatv,amdgpu,radeon" ? //修改或添加crashkernel=512M
GRUB_DISABLE_RECOVERY="true"

//更新配置
# grub2-mkconfig -o /boot/grub2/grub.cfg

//重启
# reboot


//查看 kdump 服务是否启动
[root@localhost ~]# systemctl status kdump
● kdump.service - Crash recovery kernel arming
? ?Loaded: loaded (/usr/lib/systemd/system/kdump.service; enabled; vendor preset: enabled)
? ?Active: active (exited) since Mon 2020-09-28 14:32:42 CST; 2min 39s ago
? Process: 2676 ExecStart=/usr/bin/kdumpctl start (code=exited, status=0/SUCCESS)
?Main PID: 2676 (code=exited, status=0/SUCCESS)
? ? Tasks: 0
? ?CGroup: /system.slice/kdump.service

Sep 28 14:32:42 localhost dracut[4873]: drwxr-xr-x ? 2 root ? ? root ? ? ? ? ? ?0 Sep 28 14:32 usr/share/zoneinfo/Asia
Sep 28 14:32:42 localhost dracut[4873]: -rw-r--r-- ? 1 root ? ? root ? ? ? ? ?528 Jul 11 ?2019 usr/share/zoneinfo/Asia/Shanghai
Sep 28 14:32:42 localhost dracut[4873]: drwxr-xr-x ? 2 root ? ? root ? ? ? ? ? ?0 Sep 28 14:32 var
Sep 28 14:32:42 localhost dracut[4873]: lrwxrwxrwx ? 1 root ? ? root ? ? ? ? ? 11 Sep 28 14:32 var/lock -> ../run/lock
Sep 28 14:32:42 localhost dracut[4873]: lrwxrwxrwx ? 1 root ? ? root ? ? ? ? ? ?6 Sep 28 14:32 var/run -> ../run
Sep 28 14:32:42 localhost dracut[4873]: ========================================================================
Sep 28 14:32:42 localhost dracut[4873]: *** Creating initramfs image file '/boot/initramfs-5.8.10-1.el7.elrepo.x86_64kdump.img' done ***
Sep 28 14:32:42 localhost kdumpctl[2676]: kexec: loaded kdump kernel
Sep 28 14:32:42 localhost kdumpctl[2676]: Starting kdump: [OK]
Sep 28 14:32:42 localhost systemd[1]: Started Crash recovery kernel arming.


//手动模拟crash
?#echo 1 > /proc/sys/kernel/sysrq
?#echo c > /proc/sysrq-trigger

// 若出现core dump现象,查看文件夹
# ls /var/crash/
?

文章来源:https://blog.csdn.net/u014022631/article/details/135287219
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。