Linux OS の障害対処-3
第3日目ですね。こんにちは、ニックネーム たいちょう です。
前回は、inode の枯渇について実際に枯渇させるスクリプトを走らせて実験してみました。
今日は、Microsoft Azure 上の Asinux Server 7 で kdump を採るのを実際にやってみます。
ところで、Microsoft Azure 上の Asianux Server 7 で yum update したらカーネルは次のパッケージになりました。
kernel-3.10.0-327.4.5.el7.x86_64
kdump サービスが起動しているか確認します。
# systemctl status kdump.service
Loaded: loaded (/usr/lib/systemd/system/kdump.service; enabled; vendor preset: enabled)
Active: active (exited) since Sun 2016-02-21 20:40:37 EST; 4h 28min ago
Process: 1045 ExecStart=/usr/bin/kdumpctl start (code=exited, status=0/SUCCESS)
Main PID: 1045 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/kdump.service
Feb 21 20:40:30 SP-FU-AXS7SP13 systemd[1]: Starting Crash recovery kernel arming...
Feb 21 20:40:37 SP-FU-AXS7SP13 kdumpctl[1045]: kexec: loaded kdump kernel
Feb 21 20:40:37 SP-FU-AXS7SP13 kdumpctl[1045]: Starting kdump: [OK]
Feb 21 20:40:37 SP-FU-AXS7SP13 systemd[1]: Started Crash recovery kernel arming.
# cat /etc/kdump.conf
以下を確認します。
Microsoft Azure 上の Asianux Server 7 では、/proc/sys/kernel/sysrq は、1 に設定されています。
# cat /proc/sys/kernel/sysrq
では、設定をします。
# vim /etc/default/grub
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
########## edited by taichou ###############
#GRUB_CMDLINE_LINUX="rootdelay=300 console=ttyS0 earlyprintk=ttyS0"
GRUB_CMDLINE_LINUX="rootdelay=300 console=ttyS0 earlyprintk=ttyS0 crashkernel=128M"
########## end edited by taichou ###############
GRUB_DISABLE_RECOVERY="true"
# grub2-mkconfig -o /boot/grub2/grub.cfg
Found linux image: /boot/vmlinuz-3.10.0-327.4.5.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-327.4.5.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-229.4.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-229.4.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-327.4.5.el7.x86_64.debug
Found initrd image: /boot/initramfs-3.10.0-327.4.5.el7.x86_64.debug.img
Found linux image: /boot/vmlinuz-3.10.0-327.3.1.el7.x86_64.debug
Found initrd image: /boot/initramfs-3.10.0-327.3.1.el7.x86_64.debug.img
Found linux image: /boot/vmlinuz-0-rescue-e7f5bedf25684c918aeddc8fb86caf23
Found initrd image: /boot/initramfs-0-rescue-e7f5bedf25684c918aeddc8fb86caf23.img
done
# reboot
We are no longer a registered authentication agent.
Connection to xxx.xxx.xxx.xxx closed by remote host.
Connection to xxx.xxx.xxx.xxx closed.
5 分程度待ちます。
$ ssh xxx.xxx.xxx.xxx
$ sudo su -
# cat /proc/cmdline
では、sysrq-trigger 発動です。
# echo c > /proc/sysrq-trigger
20分弱すると、下記のように接続が切れました。
同じ IPアドレスで ssh で入った後、vmcore が採れているか確認します。
# cd /var/crash
# ls
# cd 127.0.0.1-2016-02-21-20\:39\:43/
# ls
vmcore は、採れていたようです。
解析には、kernel-debuginfo パッケージが必要です。
今の例の場合、以下のパッケージになります。
kernel-debuginfo-3.10.0-327.4.5.el7.x86_64.rpm
debuginfo パッケージが合わないとどうなるのでしょうか。
# crash
Copyright (C) 2002-2014 Red Hat, Inc.
Copyright (C) 2004, 2005, 2006, 2010 IBM Corporation
Copyright (C) 1999-2006 Hewlett-Packard Co
Copyright (C) 2005, 2006, 2011, 2012 Fujitsu Limited
Copyright (C) 2006, 2007 VA Linux Systems Japan K.K.
Copyright (C) 2005, 2011 NEC Corporation
Copyright (C) 1999, 2002, 2007 Silicon Graphics, Inc.
Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.
This program is free software, covered by the GNU General Public License,
and you are welcome to change it and/or distribute copies of it under
certain conditions. Enter "help copying" to see the conditions.
This program has absolutely no warranty. Enter "help warranty" for details.
crash: cannot find booted kernel -- please enter namelist argument
Usage:
crash [OPTION]... NAMELIST MEMORY-IMAGE[@ADDRESS] (dumpfile form)
crash [OPTION]... [NAMELIST] (live system form)
Enter "crash -h" for details.
うまくいかないみたいです。
現在のカーネルのバージョンを調べます。
# uname -r
上記バージョンの
kernel-debuginfo, kernel-debuginfo-common パッケージを新たに入れました。
解析します。
# cd /var/crash/127.0.0.1-2016-02-21-20\:39\:43/
# crash /usr/lib/debug/lib/modules/3.10.0-327.4.5.el7.x86_64/vmlinux vmcore
Copyright (C) 2002-2014 Red Hat, Inc.
Copyright (C) 2004, 2005, 2006, 2010 IBM Corporation
Copyright (C) 1999-2006 Hewlett-Packard Co
Copyright (C) 2005, 2006, 2011, 2012 Fujitsu Limited
Copyright (C) 2006, 2007 VA Linux Systems Japan K.K.
Copyright (C) 2005, 2011 NEC Corporation
Copyright (C) 1999, 2002, 2007 Silicon Graphics, Inc.
Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc.
This program is free software, covered by the GNU General Public License,
and you are welcome to change it and/or distribute copies of it under
certain conditions. Enter "help copying" to see the conditions.
This program has absolutely no warranty. Enter "help warranty" for details.
GNU gdb (GDB) 7.6
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu"...
KERNEL: /usr/lib/debug/lib/modules/3.10.0-327.4.5.el7.x86_64/vmlinux
DUMPFILE: vmcore [PARTIAL DUMP]
CPUS: 1
DATE: Sun Feb 21 20:39:20 2016
UPTIME: 00:17:35
LOAD AVERAGE: 0.00, 0.02, 0.06
TASKS: 230
NODENAME: XXXXXXXX
RELEASE: 3.10.0-327.4.5.el7.x86_64
VERSION: #1 SMP Tue Feb 2 15:19:27 ICT 2016
MACHINE: x86_64 (2397 Mhz)
MEMORY: 1.7 GB
PANIC: "SysRq : Trigger a crash"
PID: 2267
COMMAND: "bash"
TASK: ffff88014c2ca280 [THREAD_INFO: ffff88014a92c000]
CPU: 0
STATE: TASK_RUNNING (SYSRQ)
crash> sys
DUMPFILE: vmcore [PARTIAL DUMP]
CPUS: 1
DATE: Sun Feb 21 20:39:20 2016
UPTIME: 00:17:35
LOAD AVERAGE: 0.00, 0.02, 0.06
TASKS: 230
NODENAME: XXXXXXXX
RELEASE: 3.10.0-327.4.5.el7.x86_64
VERSION: #1 SMP Tue Feb 2 15:19:27 ICT 2016
MACHINE: x86_64 (2397 Mhz)
MEMORY: 1.7 GB
PANIC: "SysRq : Trigger a crash"
crash> log
[ 1054.640654] Call Trace:
[ 1054.640654] [<ffffffff813b9e22>] __handle_sysrq+0xa2/0x170
[ 1054.640654] [<ffffffff813ba2ff>] write_sysrq_trigger+0x2f/0x40
[ 1054.640654] [<ffffffff812491dd>] proc_reg_write+0x3d/0x80
[ 1054.640654] [<ffffffff811de4dd>] vfs_write+0xbd/0x1e0
[ 1054.640654] [<ffffffff811def7f>] SyS_write+0x7f/0xe0
[ 1054.640654] [<ffffffff816458c9>] system_call_fastpath+0x16/0x1b
[ 1054.640654] 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 30 e9 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 ae
[ 1054.640654] RIP [<ffffffff813b9666>] sysrq_handle_crash+0x16/0x20
[ 1054.640654] RSP <ffff88014a92fe80>
[ 1054.640654] CR2: 0000000000000000
本日は以上です。ニックネーム たいちょう でした。
お疲れさまです。3日目の終了です。
次回もお楽しみに。