背景
为了 Docker、Kubernetes 运行稳定,升级 Centos 7 内核版本为 5.12.11。
升级
# 查看当前内核
$ uname -sr
Linux 3.10.0-1160.25.1.el7.x86_64
# 查看操作系统版本
$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
# 导入 ELRepo 仓库的公共密钥
$ rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
# 安装 ELRepo 仓库的 yum 源
$ yum install -y https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
# 替换为清华 ELRepo 源
$ sed -i "s/mirrorlist=/#mirrorlist=/g" /etc/yum.repos.d/elrepo.repo
$ sed -i "s#elrepo.org/linux#mirrors.tuna.tsinghua.edu.cn/elrepo#g" /etc/yum.repos.d/elrepo.repo
# (可选) 更新 yum 缓存
$ yum makecache
# 查看可用的内核版本,kernel-ml(mainline stable):稳定主线版本,kernel-lt(long term support):长期支持版本
$ yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
已加载插件:fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Loading mirror speeds from cached hostfile
* elrepo-kernel: linux-mirrors.fnal.gov
可安装的软件包
kernel-lt.x86_64 5.4.127-1.el7.elrepo elrepo-kernel
kernel-lt-devel.x86_64 5.4.127-1.el7.elrepo elrepo-kernel
kernel-lt-doc.noarch 5.4.127-1.el7.elrepo elrepo-kernel
kernel-lt-headers.x86_64 5.4.127-1.el7.elrepo elrepo-kernel
kernel-lt-tools.x86_64 5.4.127-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs.x86_64 5.4.127-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs-devel.x86_64 5.4.127-1.el7.elrepo elrepo-kernel
kernel-ml.x86_64 5.12.12-1.el7.elrepo elrepo-kernel
kernel-ml-devel.x86_64 5.12.12-1.el7.elrepo elrepo-kernel
kernel-ml-doc.noarch 5.12.12-1.el7.elrepo elrepo-kernel
kernel-ml-headers.x86_64 5.12.12-1.el7.elrepo elrepo-kernel
kernel-ml-tools.x86_64 5.12.12-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs.x86_64 5.12.12-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs-devel.x86_64 5.12.12-1.el7.elrepo elrepo-kernel
perf.x86_64 5.12.12-1.el7.elrepo elrepo-kernel
python-perf.x86_64 5.12.12-1.el7.elrepo elrepo-kernel
# 升级为主线版本
$ yum --enablerepo=elrepo-kernel install kernel-ml -y
配置开机加载
# 查看可用内核版本及启动顺序
$ sudo awk -F\' '$1=="menuentry " {print i++ " : " $2}' /boot/grub2/grub.cfg
# 查看启动顺序
$ yum install -y grub2-pc
$ grub2-editenv list
# 设置开机启动
$ grub2-set-default 0
或者
$ grub2-mkconfig -o /boot/grub2/grub.cfg
# 重启生效
$ reboot
# 重启后查看内核版本
$ uname -sr
出处:https://www.cnblogs.com/daodaotest/
如果你想及时得到个人撰写文章的消息推送,可以扫描左边二维码(或者长按识别二维码)关注个人微信公众号。
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,否则保留追究法律责任的权利。