##查看内核版本
[yym@localhost code]$ uname -a
Linux localhost.localdomain 3.10.0-1160.102.1.el7.x86_64 #1 SMP Tue Oct 17 15:42:21 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
[yym@localhost code]$ cat /proc/version
Linux version 3.10.0-1160.102.1.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) ) #1 SMP Tue Oct 17 15:42:21 UTC 2023
##导入仓库源
[yym@localhost ~]$ rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[yym@localhost ~]$ yum install -y https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
##查看可安装的软件包
[yym@localhost ~]$ yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrors.elrepo.org/mirrors-elrepo-kernel.el7 error was
12: Timeout on http://mirrors.elrepo.org/mirrors-elrepo-kernel.el7: (28, 'Connection timed out after 30047 milliseconds')
* elrepo-kernel: mirrors.tuna.tsinghua.edu.cn
Available Packages
kernel-lt-devel.x86_64 5.4.263-1.el7.elrepo elrepo-kernel
kernel-lt-doc.noarch 5.4.263-1.el7.elrepo elrepo-kernel
kernel-lt-headers.x86_64 5.4.263-1.el7.elrepo elrepo-kernel
kernel-lt-tools.x86_64 5.4.263-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs.x86_64 5.4.263-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs-devel.x86_64 5.4.263-1.el7.elrepo elrepo-kernel
kernel-ml.x86_64 6.6.5-1.el7.elrepo elrepo-kernel
kernel-ml-devel.x86_64 6.6.5-1.el7.elrepo elrepo-kernel
kernel-ml-doc.noarch 6.6.5-1.el7.elrepo elrepo-kernel
kernel-ml-headers.x86_64 6.6.5-1.el7.elrepo elrepo-kernel
kernel-ml-tools.x86_64 6.6.5-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs.x86_64 6.6.5-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs-devel.x86_64 6.6.5-1.el7.elrepo elrepo-kernel
perf.x86_64 5.4.263-1.el7.elrepo elrepo-kernel
python-perf.x86_64 5.4.263-1.el7.elrepo elrepo-kernel
##kernel-lt:longterm的缩写:长期维护版;
##kernel-ml:mainline的缩写:最新稳定版;
##安装5.4版本
[yym@localhost ~]$ yum --enablerepo=elrepo-kernel install kernel-lt-5.4.263-1.el7.elrepo
[yym@localhost ~]$ cat /boot/grub2/grub.cfg | grep menuentry ##查看系统可用内核
menuentry 'CentOS Linux (5.4.263-1.el7.elrepo.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-1160.71.1.el7.x86_64-advanced-185c6be2-c416-4329-9e89-fe7205f032cb'
[yym@localhost ~]$ grub2-set-default 'CentOS Linux (5.4.263-1.el7.elrepo.x86_64) 7 (Core)' ##设置开机从新内核启动
[yym@localhost ~]$ grub2-editenv list ##查看内核启动项
##重启
reboot ##重启