[内容] Linux 生命周期

Red Hat:

RHEL

English:

https://access.redhat.com/product-life-cycles

Or:

https://access.redhat.com/support/policy/updates/errata/#Extended_Life_Cycle_Phase

Chinese:

https://access.redhat.com/product-life-cycles?product=Red%20Hat%20Enterprise%20Linux

Or:

https://access.redhat.com/zh_CN/support/policy/updates/errata#Extended_Life_Cycle_Phase

Red Hat all products

https://access.redhat.com/product-life-cycles/update_policies

Red Hat software packages

https://access.redhat.com/support/policy/updates/rhel-app-streams-life-cycle?extIdCarryOver=true&sc_cid=701f2000001OH6fAAG

SUSE:

openSUSE

English:

https://en.opensuse.org/Lifetime

Chinese:

https://zh.opensuse.org/%E4%BD%BF%E7%94%A8%E6%9C%9F%E9%99%90

SLES

https://www.suse.com/lifecycle

[步骤] Linux Kdump 内核奔溃信息的分析 (Rocky Linux & RHEL 版)

正文:

步骤一:开启 Kdump

1.1 确保 crash 和 kernel-debuginfo 两个软件包已安装

# rpm -qa | grep crash || dnf install crash ; rpm -qa | grep kernel-debug || dnf install kernel-debug

1.2 给 Kdump 分配保留内存

1.2.1 通过在 /etc/default/grub 配置文件里修改 crashkernel 参数
# vim /etc/default/grub

在这一行里:

GRUB_CMDLINE_LINUX_DEFAULT="......"

添加:

GRUB_CMDLINE_LINUX_DEFAULT="...... crashkernel=auto"


补充:这里的 auto 代表系统会根据内存大小自动设置一个值,也可以指定一个值,例如:crashkernel=128M,high、crashkernel=256M,high 等等。如果设置成一个固定值,建议
1) 1 GB 到 4 GB 内存设置成 160 M
2) 4 GB 到 64 GB 内存设置成 192 M
3) 64 GB 到 1 TB 内存设置成 256 M
4) 大于 1 TB 内存设置成 512 M

1.2.2 让刚刚修改的内核参数生效
# grub2-mkconfig -o /boot/grub2/grub.cfg;reboot
1.2.3 显示给 Kdump 预留内存的大小
# makedumpfile --mem-usage /proc/kcore

步骤二:触发 Kdump 内核奔溃

# echo 1 > /proc/sys/kernel/sysrq
# echo c > /proc/sysrq-trigger

步骤三:分析 KDUMP 生成的内核奔溃信息

3.1 进入存放 KDUMP 内核奔溃信息的目录

# cd /var/crash/<date>/

3.2 解析 KDUMP 生成内核崩溃信息

# crash vmlinux-2.6.32.12-0.7-default vmcore

(补充:这里以使用 2.6.32.12-0.7-default 版本的 kernel-debuginfo 解析为例)

3.3 确认生成了 vmlinux-2.6.32.12-0.7-default.gz 压缩包

# ls vmlinux-2.6.32.12-0.7-default.gz

(注意:如果这里生成了 vmlinux-2.6.32.12-0.7-default.gz 压缩包的话,这里会有 vmlinux-2.6.32.12-0.7-default.gz 信息的显示)

(补充:这里以确认 2.6.32.12-0.7-default 版本的 kernel-debuginfo 生成的压缩包为例)

3.4 解压 vmlinux-2.6.32.12-0.7-default.gz 压缩包

# gzip -d vmlinux-2.6.32.12-0.7-default.gz

(补充:这里以解压 2.6.32.12-0.7-default 版本的 kernel-debuginfo 生成的压缩包为例)

3.5 分析 KDUMP 生成的内核奔溃信息

(步骤略)

参考文献:

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/managing_monitoring_and_updating_the_kernel/analyzing-a-core-dump_managing-monitoring-and-updating-the-kernel

[排错] 解决 Linux 运行时报错 “watchdog: Bug: soft lockup – CPU……” (CPU 软锁)

报错代码

watchdog: Bug: soft lockup - CPU......

分析

当 CPU 的负载过高时,一个 CPU 在运行某一个进程时,在内核模式下超过 20 秒没有回应,则看门狗程序会将系统所有 CPU 软锁住,然后会让这些 CPU 显示各自正在运行的进程堆栈跟踪

缓解方法

方法一:通过 /proc/sys/kernel/watchdog_thresh 文件延长看门狗软锁 CPU 的时间

# echo 20 > /proc/sys/kernel/watchdog_thresh

(补充:这里以将看门狗的值延长到 20 为例,也可以根据自己的需求延长更多,默认值为 10)

方法二:通过新建文件延长看门狗软所 CPU 的时间

2.1 通过新建文件延长看门狗软所 CPU 的时间

# echo "kernel.watchdog_thresh = 20" >> /etc/sysctl.conf

(补充:这里以将看门狗的值延长到 20 为例,也可以根据自己的需求延长更多,默认值为 10)

2.2 让新建文件立刻生效

# sysctl -p /etc/sysctl.conf

深究方法

开启 Kdump,等此报错再次发生时分析 Kdump 在内核崩溃时搜集信息 vmcore

[步骤] PXE 新系统模板的添加

步骤一:准备安装镜像

1.1 从官网上下载安装镜像

(步骤略)

1.2 挂载安装镜像

1.2.1 创建用于挂载安装镜像的目录
# mkdir <directory for mounting the image>
1.2.2 挂载安装镜像
# mount -t iso9660 <image> <directory for mounting the image>

步骤二:准备用于进行 PXE 安装的数据

2.1 准备系统安装数据

2.1.1 创建用于存放系统安装数据的目录
# mkdir <directory of data for installing the system>

(注意:用于存放系统安装数据的目录必须要放在能够实现 PXE 安装时网络共享的目录里(例如:通过 httpd 服务进行网络共享))

2.1.2 拷贝安装镜像里的数据到用于存放系统安装数据的目录
2.1.2.1 拷贝安装镜像里的普通数据到用于存放系统安装数据的目录
# cp -rp <directory for mounting the image>/* <directory of data for installing the system>
2.1.2.2 拷贝安装镜像里的 .treeinfo 文件到用于存放系统安装数据的目录
# cp -rp <directory for mounting the image>/.treeinfo <directory of data for installing the system>

2.2 准备安装引导文件

2.2.1 创建用于存放安装引导文件的目录
2.2.1.1 创建用于存放 BIOS 安装引导文件的目录
# mkdir <directory of BIOS boot file for installing the system>

(注意:用于存放 BIOS 安装引导文件的目录必须要放在能够实现 TFPT 网络共享的目录里)

2.2.1.2 创建用于存放 EFI 安装引导文件的目录
# mkdir <directory of EFI boot file for installing the system>

(注意:用于存放 EFI 安装引导文件的目录必须要放在能够实现 TFPT 网络共享的目录里)

2.2.2 拷贝安装镜像里的安装引导文件到存放安装引导文件的目录
2.2.2.1 拷贝安装镜像里的 BIOS 安装引导文件到存放 BIOS 安装引导文件的目录

如果是 Rocky Linux & RHEL 则拷贝 initrd.img 文件、TRANS.TBL 文件和 vmlinuz 文件:

# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/images/pxeboot/initrd.img -O <directory of BIOS boot file for installing the system>/initrd.img
# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/images/pxeboot/TRANS.TBL -O <directory of BIOS boot file for installing the system>/TRANS.TBL
# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/images/pxeboot/vmlinuz -O <directory of BIOS boot file for installing the system>/vmlinuz

如果是 openSUSE & SLES 则拷贝 linux 文件和 initrd 文件:

# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/boot/x86_64/loader/linux -O <directory of BIOS boot file for installing the system>/linux
# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/boot/x86_64/loader/initrd -O <directory of BIOS boot file for installing the system>/initrd
2.2.2.2 拷贝安装镜像里的 EFI 安装引导文件到存放 EFI 安装引导文件的目录

如果是 Rocky Linux & RHEL 则拷贝 initrd.img 文件、TRANS.TBL 文件和 vmlinuz 文件:

# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/images/pxeboot/initrd.img -O <directory of EFI boot file for installing the system>/initrd.img
# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/images/pxeboot/TRANS.TBL -O <directory of EFI boot file for installing the system>/TRANS.TBL
# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/images/pxeboot/vmlinuz -O <directory of EFI boot file for installing the system>/vmlinuz

如果是 openSUSE & SLES 则拷贝 linux 文件和 initrd 文件:

# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/boot/x86_64/loader/linux -O <directory of EFI boot file for installing the system>/linux
# curl <The URL of the network share when PXE installing>/<directory of data for installing the system>/boot/x86_64/loader/initrd -O <directory of EFI boot file for installing the system>/initrd

2.3 准备系统安装配置文件

2.3.1 进入到用于存放系统安装配置文件的目录
# cd <directory of profile for installing the system>

(注意:进入到用于存放系统安装配置文件的目录必须要放在能够实现 PXE 安装时网络共享的目录里(例如:通过 httpd 服务进行网络共享))

2.3.2 创建系统安装配置文件
2.3.2.1 创建 BIOS 系统安装配置文件

如果是 Rocky Linux & RHEL 的话

# vim <BIOS system installation profile>

(步骤略)


补充:
1) 如果是 Rocky Linux & RHEL 的话系统安装配置文件是 CFG 文件,文件名最好以 .cfg 后缀结尾
2) 如果是 openSUSE & SLES 的话系统安装配置文件是 XML 文件,文件名最好以 .xml 后缀结尾

2.3.2.2 创建 EFI 系统安装配置文件
# vim <EFI system installation profile>

(步骤略)


补充:
1) 如果是 Rocky Linux & RHEL 的话系统安装配置文件是 CFG 文件,文件名最好以 .cfg 后缀结尾
2) 如果是 openSUSE & SLES 的话系统安装配置文件是 XML 文件,文件名最好以 .xml 后缀结尾

2.3.3 设置系统安装配置文件的权限
2.3.3.1 设置 BIOS 系统安装配置文件的权限
# chmod 755 <BIOS system installation profile>
2.3.3.2 设置 EFI 系统安装配置文件的权限
# chmod 755 <EFI system installation profile>

2.4 修改系统安装菜单文件 pxelinux.cfg/default

2.4.1 修改 BIOS 系统安装菜单文件 pxelinux.cfg
# vim <directory of file for BIOS system installation menu>/pxelinux.cfg/default

如果是 Rocky Linux & RHEL 的话,添加以下内容:

......
label Rocky Linux or RHEL
  menu label ^Installation Rocky Linux or RHEL
  kernel <relative directory of pxelinux.cfg of BIOS boot file for installing the system>/vmlinuz
  append initrd=<relative directory of pxelinux.cfg of BIOS boot file for installing the system>/initrd.img ks=<The URL of the network share when PXE installing>/<BIOS system installation profile>

(注意:这里的 vmlinuz 文件和 initrd.im 文件的位置要写 pxelinux.cfg 文件的相对路径)

如果是 openSUSE & SLES 的话,添加以下内容:

......
label openSUSE or SLES
  menu label ^Installation openSUSE or SLE
  kernel <relative directory of pxelinux.cfg of BIOS boot file for installing the system>/linux
  append initrd=<relative directory of pxelinux.cfg of BIOS boot file for installing the system>/initrd splash=silent showopts install=<The URL of the network share when PXE installing>/<directory of data for installing the system>/ autoyast=<The URL of the network share when PXE installing>/<BIOS system installation profile>

(注意:这里的 linux 文件和 initrd 文件的位置要写 pxelinux.cfg 文件的相对路径)

(注意:用于存放 BIOS 系统安装菜单文件的目录必须要放在能够实现 TFPT 网络共享的目录里)

2.4.2 修改 EFI 系统安装菜单文件 grub.cfg
# vim <directory of file for EFI system installation menu>/grub.cfg

如果是 Rocky Linux & RHEL 的话,添加以下内容:

......
menuentry 'label Rocky Linux or RHEL' {
  linuxefi <relative directory of pxelinux.cfg of EFI boot file for installing the system>/vmlinuz ks=<The URL of the network share when PXE installing>/<EFI system installation profile>
  initrdefi <relative directory of pxelinux.cfg of EFI boot file for installing the system>/initrd.img
}

(注意:这里的 vmlinuz 文件和 initrd.im 文件的位置要写 pxelinux.cfg 文件的相对路径)

如果是 openSUSE & SLES 的话,添加以下内容:

......
menuentry 'label openSUSE or SUSE' {
  linuxefi <relative directory of linux of EFI boot file for installing the system>/linux install=<The URL of openSUSE or SUSE image> autoyast=<The URL of the network share when PXE installing>/<EFI system installation profile>
  initrdefi <relative directory of pxelinux.cfg of EFI boot file for installing the system>/initrd.img
}

(注意:这里的 linux 文件和 initrd 文件的位置要写 pxelinux.cfg 文件的相对路径)

(注意:用于存放 EFI 系统安装菜单文件的目录必须要放在能够实现 TFPT 网络共享的目录里)

步骤三:取消挂载安装镜像

# umount <directory for mounting the image>

[命令] Linux 命令 hdparm (测试硬盘读取速度)

 # hdparm -Ttv /dev/sda

/dev/sda:
 multcount     = 128 (on)
 IO_support    =  1 (32-bit)
 readonly      =  0 (off)
 readahead     = 1024 (on)
 geometry      = 8354/255/63, sectors = 134217728, start = 0
 Timing cached reads:   7304 MB in  2.00 seconds = 3658.90 MB/sec
 Timing buffered disk reads: 612 MB in  3.01 seconds = 203.07 MB/sec

(补充:这里以测试 /dev/sda 硬盘的读取速度为例)