kdump
实验环境:
client OS: Red Hat Enterprise Linux 5 update 2
client IP: 10.66.0.157
server OS: Red Hat Enterprise Linux 4 update 7
server IP: 10.66.0.84
kdump属于kexec-tools-1.102pre-21.el5这个包。一般装系统都有装上。
kdump支持N种方式存储内存数据,包括裸设备,文件系统,nfs,ssh。并且能设定dump
前和dump后运行脚本以及执行其他动作。正所谓很好很强大。
kdump的dump机制是:预先生成一个crashkernel,在内核crash的时候,激活这个
crashkernel,用这个crashkernel载入的小型系统dump处于crash状态的内核。
实验步骤:
这次我会配置kdump把内存数据scp到备份服务器上。
在client上:
安装kdump
[root@dhcp-0-157 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.2 (Tikanga)
[root@dhcp-0-157 ~]# cd /misc/cd/Server
[root@dhcp-0-157 Server]# rpm -ivh busybox-1.2.0-4.el5.i386.rpm
warning: busybox-1.2.0-4.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID
37017186
Preparing… ########################################### [100%]
1:busybox ########################################### [100%]
[root@dhcp-0-157 Server]# rpm -ivh kexec-tools-1.102pre-21.el5.i386.rpm
warning: kexec-tools-1.102pre-21.el5.i386.rpm: Header V3 DSA signature: NOKEY,
key ID 37017186
Preparing… ########################################### [100%]
1:kexec-tools ########################################### [100%]
[root@dhcp-0-157 Server]#
配置kdump
[root@dhcp-0-157 ~]# vim /etc/kdump.conf
net root@10.66.0.84
对kernel开启kdump支持
[root@dhcp-0-157 ~]# vim /boot/grub/grub.conf
在kernel选项上添加crashkernel参数。
参数格式是:
crashkernel=nn[KMG]@ss[KMG]
nn表示要为crashkernel预留多少内存
ss表示为crashkernel预留内存的起始位置
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-92.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-92.el5 ro root=LABEL=/ crashkernel=256M@16M
initrd /initrd-2.6.18-92.el5.img
重启电脑使新参数生效。
然后启用kdump服务
[root@dhcp-0-157 ~]# service kdump
Usage: /etc/init.d/kdump {start|stop|status|restart|propagate}
[root@dhcp-0-157 ~]# service kdump propagate
Generating new ssh keys… done.
The authenticity of host ‘10.66.0.84 (10.66.0.84)’ can’t be established.
RSA key fingerprint is 31:c2:d8:b6:eb:2e:03:64:cd:ba:56:e9:49:6e:5d:6c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘10.66.0.84′ (RSA) to the list of known hosts.
root@10.66.0.84’s password:
/root/.ssh/kdump_id_rsa.pub has been added to ~root/.ssh/authorized_keys2 on
10.66.0.84
[root@dhcp-0-157 ~]# service kdump restart
Stopping kdump:[ OK ]
No kdump initial ramdisk found.[WARNING]
Rebuilding /boot/initrd-2.6.18-92.el5kdump.img
Starting kdump:[ OK ]
[root@dhcp-0-157 ~]# chkconfig –level 35 kdump on
[root@dhcp-0-157 ~]#
最后模拟crash:
[root@dhcp-0-157 ~]# echo 1 > /proc/sys/kernel/sysrq
[root@dhcp-0-157 ~]# echo c > /proc/sysrq-trigger
在server的/var/crash下可以看到由client转储过来的内核数据。
另外,kdump在完成内核转储后会自动重启。