欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

centos-kudump使用

程序员文章站 2022-04-29 19:54:48
...

1、安装kexec-tools

[[email protected]_0_11_centos ~]# yum -y install kexec-tools
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * elrepo: mirrors.tuna.tsinghua.edu.cn
Package kexec-tools-2.0.15-33.el7.x86_64 already installed and latest version
Nothing to do

 2、配置kdump

1)修改grub文件

crashkernel=128M,配置保留的内存空间为128M
[[email protected]_0_11_centos ~]# cat /etc/default/grub 
GRUB_TIMEOUT=20
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=1
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL="serial console"
GRUB_TERMINAL_OUTPUT="serial console"
GRUB_CMDLINE_LINUX="crashkernel=128M console=ttyS0 console=tty0 panic=5 net.ifnames=0 biosdevname=0"
GRUB_DISABLE_RECOVERY="true"
GRUB_SERIAL_COMMAND="serial --speed=9600 --unit=0 --word=8 --parity=no --stop=1"

2)生成grub配置文件 

只要更改了gurb文件,都需要更改grub配置
[[email protected]_0_11_centos ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.2-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-5.4.2-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1062.9.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1062.9.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-957.21.3.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.21.3.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-0ea734564f9a4e2881b866b82d679dfc
Found initrd image: /boot/initramfs-0-rescue-0ea734564f9a4e2881b866b82d679dfc.img
done

3、模拟kdump

1)core文件

默认core文件存放在/var/crash目录下

配置文件/etc/kdump.conf

#raw /dev/vg/lv_kdump
#ext4 /dev/vg/lv_kdump
#ext4 LABEL=/boot
#ext4 UUID=03138356-5e61-4ab3-b58e-27507ac41937
#nfs my.server.com:/export/tmp
#ssh [email protected]
#sshkey /root/.ssh/kdump_id_rsa
path /var/crash
core_collector makedumpfile -l --message-level 1 -d 31
#core_collector scp
#kdump_post /var/crash/scripts/kdump-post.sh
#kdump_pre /var/crash/scripts/kdump-pre.sh
#extra_bins /usr/bin/lftp
#extra_modules gfs2
#default shell

2)设置为开机自启

[[email protected]_0_11_centos ~]# systemctl enable kdump
[[email protected]_0_11_centos ~]# 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 Wed 2019-12-11 23:44:40 CST; 1 day 23h ago
 Main PID: 1180 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/kdump.service

Dec 11 23:44:35 VM_0_11_centos systemd[1]: Starting Crash recovery kernel arming...
Dec 11 23:44:40 VM_0_11_centos kdumpctl[1180]: kexec: loaded kdump kernel
Dec 11 23:44:40 VM_0_11_centos kdumpctl[1180]: Starting kdump: [OK]
Dec 11 23:44:40 VM_0_11_centos systemd[1]: Started Crash recovery kernel arming.

3)重启

reboot

4、生成core文件

1)生成core文件

echo c > /proc/sysrq-trigger

2)查看生成的core文件

[[email protected]_0_11_centos ~]# ll /var/crash
total 4
drwxr-xr-x 2 root root 4096 Dec 13 23:32 127.0.0.1-2019-12-13-23:32:35

 

 

相关标签: Linux专栏