- 工信部備案號 滇ICP備05000110號-1
- 滇公安備案 滇53010302000111
- 增值電信業務經營許可證 B1.B2-20181647、滇B1.B2-20190004
- 云南互聯網協會理事單位
- 安全聯盟認證網站身份V標記
- 域名注冊服務機構許可:滇D3-20230001
- 代理域名注冊服務機構:新網數碼
在使用 CentOS 的過程中,常常會面臨各種挑戰,其中一個重要的方面就是內核的升級問題。隨著應用環境的不斷發展,高版本的應用對內核的要求也日益提高,因此內核升級變得不可或缺。然而,當 CentOS 7 停止維護后,內核的升級過程就不再像以往那樣簡單,會遇到諸多新情況。
但是在 centos 7 停止維護之后,無法使用 yum 直接升級內核,執行下面的命令時,已經不顯示內核版本了。
[root@k8s-master01 ~]# yum list available --disablerepo=* --enablerepo=elrepo-kernel
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
* elrepo-kerne
l: mirrors.tuna.tsing
hua.edu.cn
elrepo-kernel | 3.0 kB 00:00:00
elrepo-kernel/primary_db | 2.2 kB 00:00:00
Available Packageselrepo-release.noarch 7.0-8.el7.elrepo elrepo-kernel
關于內核種類:
kernel-ml :ml = mainline,主流版本
kernel-lt :lt = long-term ,長期有效
ML 與 LT 兩種內核類型版本可以共存,但每種類型內核只能存在一個版本。
kernel rpm 歷史版本:
導入公鑰
查看內核版本
[root@k8s-master01 ~]# uname -r
3.10.0-1160.119.1.el7.x86_64
開始安裝新版本的內核
[root@k8s-master01 ~]# rpm -ih kernel-ml-6.9.7-1.el7.elrepo.x86_64.rpm
################################# [100%]
Updating / installing...
################################# [100%]
[root@k8s-master01 ~]# rpm -ih kernel-ml-devel-6.9.7-1.el7.elrepo.x86_64.rpm
################################# [100%]
Updating / installing...
################################# [100%]
[root@k8s-master01 ~]# rpm -ih kernel-ml-headers-6.9.7-1.el7.elrepo.x86_64.rpm
error: Failed dependencies:
kernel-headers < 6.9.7-1.el7.elrepo conflicts with kernel-ml-headers-6.9.7-1.el7.elrepo.x86_64
kernel-ml-headers 安裝時提示沖突報錯
要解決這個問題,需要先重啟到最新的內核,然后卸載舊內核,再次安裝即可。
查看已安裝的內核版本:
[root@k8s-master01 ~]# awk -F\\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
0 : CentOS Linux 7 Rescue c699e4abb55f41d2894c5e5d076ece00 (6.9.7-1.el7.elrepo.x86_64)
1 : CentOS Linux (6.9.7-1.el7.elrepo.x86_64) 7 (Core)
2 : CentOS Linux 7 Rescue 3708a8c5ffaf41ec8c2b6c256447b9d3 (3.10.0-1160.119.1.el7.x86_64)
3 : CentOS Linux (3.10.0-1160.119.1.el7.x86_64) 7 (Core)
4 : CentOS Linux (0-rescue-e824c70f6df443479545152398478c6f) 7 (Core)
可以看到最新安裝的內核是 0 ,所以需要將最新內核 0 設置為默認引導。
[root@k8s-master01 ~]# grub2-set-default 0
生成 grub配置文件
[root@k8s-master01 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.9.7-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-6.9.7-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.119.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.119.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-3708a8c5ffaf41ec8c2b6c256447b9d3
Found initrd image: /boot/initramfs-0-rescue-3708a8c5ffaf41ec8c2b6c256447b9d3.img
Found linux image: /boot/vmlinuz-0-rescue-5ea3132971dd43e59cf37c5576c6ec0e
Found initrd image: /boot/initramfs-0-rescue-5ea3132971dd43e59cf37c5576c6ec0e.img
Found linux image: /boot/vmlinuz-0-rescue-e824c70f6df443479545152398478c6f
Found initrd image: /boot/initramfs-0-rescue-e824c70f6df443479545152398478c6f.img
done
重啟服務器
[root@k8s-master01 ~]# reboot
最后再安裝 kernel-ml-headers
[root@k8s-master01 ~]# rpm -ih kernel-ml-headers-6.9.7-1.el7.elrepo.x86_64.rpm################################# [100%]Updating / installing...################################# [100%]
查看當前的內核版本
[root@k8s-master01 ~]# uname -r6.9.7-1.el7.elrepo.x86_64
通過以上一系列操作,我們成功解決了 CentOS 7 停止維護后內核升級的問題。盡管過程中遇到了諸如 kernel-ml-headers 安裝沖突等困難,但最終還是實現了內核的順利更新,為我們在更高版本應用環境下的使用提供了保障。
售前咨詢
售后咨詢
備案咨詢
二維碼
TOP