步骤一:检查内核版本
[root@master ~]# uname -rs
Linux 3.10.0-1160.el7.x86_64
步骤二:升级内核
CentOS 允许使用 ELRepo,这是一个第三方仓库,可以将内核升级到最新版本
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org #导入该源的秘钥
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm #启用该源仓库
yum --disablerepo="*" --enablerepo="elrepo-kernel" list available #查看有哪些内核版本可供安装
[root@node1 ~]# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available 已加载插件:fastestmirror Loading mirror speeds from cached hostfile Could not retrieve mirrorlist http://mirrors.elrepo.org/mirrors-elrepo-kernel.el7 error was 14: curl#7 - "Failed connect to mirrors.elrepo.org:80; 拒绝连接" * elrepo-kernel: repos.lax-noc.com elrepo-kernel | 3.0 kB 00:00:00 elrepo-kernel/primary_db | 2.1 MB 00:00:03 可安装的软件包 elrepo-release.noarch 7.0-6.el7.elrepo elrepo-kernel kernel-lt.x86_64 5.4.224-1.el7.elrepo elrepo-kernel kernel-lt-devel.x86_64 5.4.224-1.el7.elrepo elrepo-kernel kernel-lt-doc.noarch 5.4.224-1.el7.elrepo elrepo-kernel kernel-lt-headers.x86_64 5.4.224-1.el7.elrepo elrepo-kernel kernel-lt-tools.x86_64 5.4.224-1.el7.elrepo elrepo-kernel kernel-lt-tools-libs.x86_64 5.4.224-1.el7.elrepo elrepo-kernel kernel-lt-tools-libs-devel.x86_64 5.4.224-1.el7.elrepo elrepo-kernel kernel-ml.x86_64 6.0.9-1.el7.elrepo elrepo-kernel kernel-ml-devel.x86_64 6.0.9-1.el7.elrepo elrepo-kernel kernel-ml-doc.noarch 6.0.9-1.el7.elrepo elrepo-kernel kernel-ml-headers.x86_64 6.0.9-1.el7.elrepo elrepo-kernel kernel-ml-tools.x86_64 6.0.9-1.el7.elrepo elrepo-kernel kernel-ml-tools-libs.x86_64 6.0.9-1.el7.elrepo elrepo-kernel kernel-ml-tools-libs-devel.x86_64 6.0.9-1.el7.elrepo elrepo-kernel perf.x86_64 5.4.224-1.el7.elrepo elrepo-kernel python-perf.x86_64
步骤三:开始升级内核(选择一个)
yum --enablerepo=elrepo-kernel install kernel-ml -y #安装的是最新的稳定主线版本,该版本比较激进,慎重选择。版本:6.0.9
yum --enablerepo=elrepo-kernel install kernel-lt -y #安装的长期支持版本,稳定可靠. 版本: 5.4.224
yum --enablerepo=elrepo-kernel install kernel-lt kernel-lt-devel -y # k8s版本
安装完毕后,重启机器,手动选择新安装的新版本
步骤四:设置 GRUB 默认的内核版本
查看系统上的所有可用内核:
[root@node1 ~]# awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg 0 : CentOS Linux (5.4.224-1.el7.elrepo.x86_64) 7 (Core) 1 : CentOS Linux (0-rescue-ae49e21e0f4f49d98d75fad6053c0411) 7 (Core)
# 问题1:/etc/grub2.cfg 没有这个文件 /etc/grub2.cfg文件是一个文件链接,实际链接到/boot/grub2/grub.cfg # 问题2:没有/boot/grub2/grub.cfg这个文件或目录 mkdir /boot/grub2 grub2-mkconfig -o /boot/grub2/grub.cfg # 重建内核配置文件 ln -s /boot/grub2/grub.cfg /etc/grub2.cfg
4.1 设置启动顺序:
grub2-set-default 0
打开并编辑 /etc/default/grub
并设置 GRUB_DEFAULT=0
。意思是 GRUB 初始化页面的第一个内核将作为默认内核
[root@node1 grub2]# cat /etc/default/grub GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=0 GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="crashkernel=auto spectre_v2=retpoline rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet" GRUB_DISABLE_RECOVERY="true"
4.2 执行命令:
grub2-mkconfig -o /boot/grub2/grub.cfg
标签:kernel,x86,Centos,elrepo,grub2,64,内核,版本,el7 From: https://www.cnblogs.com/yangmeichong/p/16912119.html