由於需要驗證一個問題,需要將CentOS7內核升級至5.x版本
[root@k8s ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[root@k8s ~]# uname -a
Linux k8s 3.10.0-1062.18.1.el7.x86_64 #1 SMP Tue Mar 17 23:49:17 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
elrepo倉庫支援Red Hat Enterprise Linux(RHEL)及其衍生版本(Scientific Linux,CentOS等)。
參考:http://elrepo.org/tiki/tiki-index.php
[root@k8s ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[root@k8s ~]# yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
Loaded plugins: fastestmirror
elrepo-release-7.el7.elrepo.noarch.rpm | 8.6 kB 00:00:00
Examining /var/tmp/yum-root-GHYeAv/elrepo-release-7.el7.elrepo.noarch.rpm: elrepo-release-7.0-5.el7.elrepo.noarch
Marking /var/tmp/yum-root-GHYeAv/elrepo-release-7.el7.elrepo.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package elrepo-release.noarch 0:7.0-5.el7.elrepo will be installed
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================================================
Package Arch Version Repository Size
============================================================================================================================================================================
Installing:
elrepo-release noarch 7.0-5.el7.elrepo /elrepo-release-7.el7.elrepo.noarch 5.0 k
Transaction Summary
============================================================================================================================================================================
Install 1 Package
Total size: 5.0 k
Installed size: 5.0 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : elrepo-release-7.0-5.el7.elrepo.noarch 1/1
Verifying : elrepo-release-7.0-5.el7.elrepo.noarch 1/1
Installed:
elrepo-release.noarch 0:7.0-5.el7.elrepo
Complete!
[root@k8s ~]# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
Loaded plugins: fastestmirror
Determining fastest mirrors
* elrepo-kernel: mirror-hk.koddos.net
elrepo-kernel | 2.9 kB 00:00:00
elrepo-kernel/primary_db | 1.9 MB 00:00:00
Available Packages
kernel-lt.x86_64 4.4.232-1.el7.elrepo elrepo-kernel
kernel-lt-devel.x86_64 4.4.232-1.el7.elrepo elrepo-kernel
kernel-lt-doc.noarch 4.4.232-1.el7.elrepo elrepo-kernel
kernel-lt-headers.x86_64 4.4.232-1.el7.elrepo elrepo-kernel
kernel-lt-tools.x86_64 4.4.232-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs.x86_64 4.4.232-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs-devel.x86_64 4.4.232-1.el7.elrepo elrepo-kernel
kernel-ml.x86_64 5.8.0-1.el7.elrepo elrepo-kernel
kernel-ml-devel.x86_64 5.8.0-1.el7.elrepo elrepo-kernel
kernel-ml-doc.noarch 5.8.0-1.el7.elrepo elrepo-kernel
kernel-ml-headers.x86_64 5.8.0-1.el7.elrepo elrepo-kernel
kernel-ml-tools.x86_64 5.8.0-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs.x86_64 5.8.0-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs-devel.x86_64 5.8.0-1.el7.elrepo elrepo-kernel
perf.x86_64 5.8.0-1.el7.elrepo elrepo-kernel
python-perf.x86_64 5.8.0-1.el7.elrepo elrepo-kernel
其中lt爲4.4版本,ml是5.8版本,所以這裏我們需要安裝ml版本
[root@k8s ~]# yum install kernel-ml --enablerepo=elrepo-kernel -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* elrepo: mirror-hk.koddos.net
* elrepo-kernel: mirror-hk.koddos.net
Resolving Dependencies
--> Running transaction check
---> Package kernel-ml.x86_64 0:5.8.0-1.el7.elrepo will be installed
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================================================
Package Arch Version Repository Size
============================================================================================================================================================================
Installing:
kernel-ml x86_64 5.8.0-1.el7.elrepo elrepo-kernel 51 M
Transaction Summary
============================================================================================================================================================================
Install 1 Package
Total download size: 51 M
Installed size: 232 M
Downloading packages:
kernel-ml-5.8.0-1.el7.elrepo.x86_64.rpm | 51 MB 00:00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : kernel-ml-5.8.0-1.el7.elrepo.x86_64 1/1
Verifying : kernel-ml-5.8.0-1.el7.elrepo.x86_64 1/1
Installed:
kernel-ml.x86_64 0:5.8.0-1.el7.elrepo
Complete!
這裏如果下載很慢,可以提前https://elrepo.org/linux/kernel/el7/x86_64/RPMS/ (手動下載包)在這裏下載好
檢視預設的啓動順序
[root@k8s ~]# awk -F\' '$1=="menuentry " {print $2}' /boot/grub2/grub.cfg
CentOS Linux (5.8.0-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-1062.18.1.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-1062.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-20200426154603174201708213343640) 7 (Core)
修改cat /etc/default/grub,將GRUB_DEFAULT的值設定爲0,重新啓動後就會使用新內核
[root@k8s ~]# sed -i 's/GRUB_DEFAULT=saved/GRUB_DEFAULT=0/g' /etc/default/grub
最後執行grub2-mkconfig重新整理一下設定
[root@k8s ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.8.0-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-5.8.0-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1062.18.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1062.18.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1062.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1062.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-20200426154603174201708213343640
Found initrd image: /boot/initramfs-0-rescue-20200426154603174201708213343640.img
done
[root@k8s ~]# uname -a
Linux k8s 5.8.0-1.el7.elrepo.x86_64 #1 SMP Sun Aug 2 18:18:16 EDT 2020 x86_64 x86_64 x86_64 GNU/Linux
升級成功