需求:由于客户容器化的需要,需要将当前的操作系统升级为5.10.7的版本。
内核升级操作步骤如下:
步骤一:载入公钥、安装elrepo
代码语言:javascript复制rpm -import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
步骤二、载入elrepo-kernel元数据
代码语言:javascript复制yum --disablerepo=* --enablerepo=elrepo-kernel repolist
步骤三、查看可用rpm、并且安装
- 查看可用安装(其中关键字 lt 是稳定版、 mt标识是最新版)
[root@taitao-k8s-hz-basic-25 ~]# yum --disablerepo=* --enablerepo=elrepo-kernel list kernel*
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* elrepo-kernel: mirrors.neusoft.edu.cn
Installed Packages
kernel.x86_64 3.10.0-1160.el7 @anaconda
kernel.x86_64 3.10.0-1160.11.1.el7 @updates
kernel-devel.x86_64 3.10.0-1160.11.1.el7 @updates
kernel-headers.x86_64 3.10.0-1160.11.1.el7 @updates
kernel-ml.x86_64 5.10.7-1.el7.elrepo @elrepo-kernel
kernel-ml-devel.x86_64 5.10.7-1.el7.elrepo @elrepo-kernel
kernel-ml-tools.x86_64 5.10.7-1.el7.elrepo @elrepo-kernel
kernel-ml-tools-libs.x86_64 5.10.7-1.el7.elrepo @elrepo-kernel
Available Packages
kernel-lt.x86_64 5.4.89-1.el7.elrepo elrepo-kernel
kernel-lt-devel.x86_64 5.4.89-1.el7.elrepo elrepo-kernel
kernel-lt-doc.noarch 5.4.89-1.el7.elrepo elrepo-kernel
kernel-lt-headers.x86_64 5.4.89-1.el7.elrepo elrepo-kernel
kernel-lt-tools.x86_64 5.4.89-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs.x86_64 5.4.89-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs-devel.x86_64 5.4.89-1.el7.elrepo elrepo-kernel
kernel-ml-doc.noarch 5.10.7-1.el7.elrepo elrepo-kernel
kernel-ml-headers.x86_64 5.10.7-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs-devel.x86_64
- 安装
yum -y --enablerepo=elrepo-kernel install kernel-ml.x86_64 kernel-ml-tools.x86_64
yum remove kernel-tools-libs.x86_64 kernel-tools.x86_64
步骤四:查看系统上的所有可用内核
代码语言:javascript复制[root@taitao-k8s-hz-basic-25 ~]# awk -F' '$1=="menuentry " {print $2}' /etc/grub2.cfg
CentOS Linux (5.10.7-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-1160.11.1.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-1160.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-20201228113502924739250506992733) 7 (Core)
[root@maitao-k8s-hz-basic-25 ~]# vim /etc/default/grub
步骤五:设置开机从新内核启动
- 方法1:
grub2-set-default 0
- 方法2:
编辑配置文件 vim /etc/default/grub
将GRUB_DEFAULT=saved改为GRUB_0=saved,保存退出vim。
步骤六:运行grub2-mkconfig命令来重新创建内核配置
代码语言:javascript复制grub2-mkconfig -o /boot/grub2/grub.cfg
步骤七、重启动、查看内核、更新
代码语言:javascript复制reboot
uname -r
yum update
升级版本
[root@cainiao-k8s-hz-rancher ~]# uname -r
5.10.7-1.el7.elrepo.x86_64