步骤一:理解 Kdump 的作用
开启 core dump 之后,如果出现了 C 语言程序的 crash,则会将 crash 的结果记录到一个文件里
步骤二:临时开启 Kdump
2.1 设置可生成 Kdump 大小的参数
2.1.1 显示当前允许生成 Kdump 的大小
# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 31722
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 31722
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
2.1.2 将允许生成 Kdump 大小的参数设置为无限大
# ulimit -c unlimited
2.1.3 确认修改结果
# ulimit -a
core file size (blocks, -c) unlimited
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 31722
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 31722
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
2.2 设置 Kdump 生成的位置
# sysctl -w kernel.core_pattern=/tmp/corefile/core-%e-%p
步骤三:此时如果有 C 语言的程序 crash 了,则会被自动记录