本文小编为大家详细介绍“Linux怎么正确捕捉内核崩溃信息”,内容详细,步骤清晰,细节处理妥当,希望这篇“Linux怎么正确捕捉内核崩溃信息”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。

首先安装必选包:

apt-get-yinstallaptitudekdump-toolscrashkexec-toolsmakedumpfilelinux-image-`uname-r`-dbgaptitudefull-upgrade#避免运行的内核版本与调试的版本不一致导致无法调试Kdump配置文件 /etc/default/kdump-tools 关键部分

USE_KDUMP=1KDUMP_SYSCTL="kernel.panic_on_oops=1"KDUMP_KERNEL=/boot/vmlinuz-3.16.0-4-amd64KDUMP_INITRD=/boot/initrd.img-3.16.0-4-amd64KDUMP_COREDIR="/data/crash"KDUMP_FAIL_CMD="reboot-f"DEBUG_KERNEL=/usr/lib/debug/vmlinux-3.16.0-4-amd64MAKEDUMP_ARGS="-c-d31"KDUMP_CMDLINE="crashkernel=512M"crashkernel大小配比,正常情况崩溃后1分钟左右会自动重启、配置不正确会导致重启卡住黑屏不动。

内存大小crashkernel=0-12G128M13-48G256M49-128G512M129-256G1G*(896M,768Mo或512M)Grub配置文件/etc/default/grub关键部分

GRUB_CMDLINE_LINUX_DEFAULT=”nmi_watchdog=1 crashkernel=512M”

Sysctl配置文件/etc/sysctl.conf关键部分

kernel.sysrq=1kernel.watchdog=1kernel.nmi_watchdog=1kernel.panic_on_oops=1kernel.softlockup_panic=1kernel.watchdog_thresh=10重启让配置生效

update-grubreboot-fkdump-configloadkdump-configshow校验

#cat/proc/cmdlineBOOT_IMAGE=/boot/vmlinuz-3.16.0-4-amd64root=UUID=a58ab901-00aa-4f8b-b3eb-d352fc72233ronet.ifnames=0thash_entries=1048576rhash_entries=1048576biosdevname=0nohz=offenforcing=0ipv6.disable_ipv6=1nmi_watchdog=1selinux=0transparent_hugepage=nevercgroup_enable=memoryswapaccount=1vga=771crashkernel=512M#kdump-configtestUSE_KDUMP:1KDUMP_SYSCTL:kernel.panic_on_oops=1KDUMP_COREDIR:/data/crashcrashkerneladdr:0x2e000000kdumpkerneladdr:kdumpkernel:/boot/vmlinuz-3.16.0-4-amd64kdumpinitrd:/boot/initrd.img-3.16.0-4-amd64debugkernel:/usr/lib/debug/vmlinux-3.16.0-4-amd64kexeccommandtobeused:/sbin/kexec-p--command-line="BOOT_IMAGE=/boot/vmlinuz-3.16.0-4-amd64root=UUID=a58ab901-00aa-4f8b-b3eb-d352fc7f6acbronet.ifnames=0thash_entries=1048576rhash_entries=1048576biosdevname=0nohz=offenforcing=0ipv6.disable_ipv6=1nmi_watchdog=1selinux=0transparent_hugepage=nevercgroup_enable=memoryswapaccount=1vga=771irqpollmaxcpus=1nousbsystemd.unit=kdump-tools.servicecrashkernel=512M"--initrd=/boot/initrd.img-3.16.0-4-amd64/boot/vmlinuz-3.16.0-4-amd64测试

echoc>/proc/sysrq-trigger

分析

crash/data/crash/201609010252/dump.201609012233/usr/lib/debug/lib/modules/3.16.0-4-amd64/vmlinux

开始欢快的调试之旅
常用错误 :

WARNING:kernelversioninconsistencybetweenvmlinuxanddumpfile#版本不一致,full-upgrade一下。崩溃后系统不重启。#请检查sysctl、crashkernel及nmi_watchdog的设定!

读到这里,这篇“Linux怎么正确捕捉内核崩溃信息”文章已经介绍完毕,想要掌握这篇文章的知识点还需要大家自己动手实践使用过才能领会,如果想了解更多相关内容的文章,欢迎关注亿速云行业资讯频道。