1. 检查现有 kernel 版本
[root@aws-172-20-20-101 deploy]# uname -r
3.10.0-957.12.2.el7.x86_64
2. 添加 elrepo repository
# import ElRepo’s GPG keys
[root@aws-172-20-20-101 deploy]# sudo rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
# install the repository
[root@aws-172-20-20-101 deploy]# rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
获取https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
准备中...
################################# [100%]
正在升级/安装...
1:elrepo-release-7.0-3.el7.elrepo ################################# [100%]
查看确认 repo 是否安装
[root@aws-172-20-20-101 deploy]# yum repolist
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.jdcloud.com
* elrepo: mirrors.neusoft.edu.cn
* epel: mirror.lzu.edu.cn
* extras: mirror.jdcloud.com
* updates: mirrors.cqu.edu.cn
elrepo | 2.9 kB 00:00:00
elrepo/primary_db | 289 kB 00:00:00
源标识 源名称 状态
base/7/x86_64 CentOS-7 - Base 10,019
elrepo ELRepo.org Community Enterprise Linux Repository - el7 109
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,220
extras/7/x86_64 CentOS-7 - Extras 409
saltstack/x86_64 SaltStack latest Release Channel for RHEL/CentOS 7 108
updates/7/x86_64 CentOS-7 - Updates 1,982
repolist: 25,847
3. 列出可用内核安装包
[root@aws-172-20-20-101 deploy]# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* elrepo-kernel: mirrors.neusoft.edu.cn
elrepo-kernel
elrepo-kernel/primary_db | 1.8 MB 00:00:00
可安装的软件包
kernel-lt.x86_64 4.4.180-2.el7.elrepo elrepo-kernel
kernel-lt-devel.x86_64 4.4.180-2.el7.elrepo elrepo-kernel
kernel-lt-doc.noarch 4.4.180-2.el7.elrepo elrepo-kernel
kernel-lt-headers.x86_64 4.4.180-2.el7.elrepo elrepo-kernel
kernel-lt-tools.x86_64 4.4.180-2.el7.elrepo elrepo-kernel
kernel-lt-tools-libs.x86_64 4.4.180-2.el7.elrepo elrepo-kernel
kernel-lt-tools-libs-devel.x86_64 4.4.180-2.el7.elrepo elrepo-kernel
kernel-ml.x86_64 5.1.8-1.el7.elrepo elrepo-kernel
kernel-ml-devel.x86_64 5.1.8-1.el7.elrepo elrepo-kernel
kernel-ml-doc.noarch 5.1.8-1.el7.elrepo elrepo-kernel
kernel-ml-headers.x86_64 5.1.8-1.el7.elrepo elrepo-kernel
kernel-ml-tools.x86_64 5.1.8-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs.x86_64 5.1.8-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs-devel.x86_64 5.1.8-1.el7.elrepo elrepo-kernel
perf.x86_64 5.1.8-1.el7.elrepo elrepo-kernel
python-perf.x86_64 5.1.8-1.el7.elrepo elrepo-kernel
4. 安装最新版本的 LTS Kernel
[root@aws-172-20-20-101 deploy]# sudo yum --enablerepo=elrepo-kernel install kernel-lt
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.jdcloud.com
* elrepo: mirrors.neusoft.edu.cn
* elrepo-kernel: mirrors.neusoft.edu.cn
* epel: mirror.lzu.edu.cn
* extras: mirror.jdcloud.com
* updates: mirrors.cqu.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 kernel-lt.x86_64.0.4.4.180-2.el7.elrepo 将被 安装
--> 解决依赖关系完成
依赖关系解决
=========================================================================================================================================================================================
Package 架构 版本 源 大小
=========================================================================================================================================================================================
正在安装:
kernel-lt x86_64 4.4.180-2.el7.elrepo elrepo-kernel 39 M
事务概要
=========================================================================================================================================================================================
安装 1 软件包
总下载量:39 M
安装大小:180 M
Is this ok [y/d/N]: y
Downloading packages:
kernel-lt-4.4.180-2.el7.elrepo.x86_64.rpm | 39 MB 00:00:04
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
警告:RPM 数据库已被非 yum 程序修改。
正在安装 : kernel-lt-4.4.180-2.el7.elrepo.x86_64 1/1
验证中 : kernel-lt-4.4.180-2.el7.elrepo.x86_64 1/1
已安装:
kernel-lt.x86_64 0:4.4.180-2.el7.elrepo
完毕!
5. 查看当前系统有几个内核版本
[root@aws-172-20-20-101 deploy]# cat /boot/grub2/grub.cfg |grep menuentry
if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
menuentry_id_option=""
export menuentry_id_option
menuentry 'CentOS Linux (4.4.180-2.el7.elrepo.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-862.3.2.el7.x86_64-advanced-8c1540fa-e2b4-407d-bcd1-59848a73e463' {
menuentry 'CentOS Linux (3.10.0-957.12.2.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-862.3.2.el7.x86_64-advanced-8c1540fa-e2b4-407d-bcd1-59848a73e463' {
menuentry 'CentOS Linux (3.10.0-862.3.2.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-862.3.2.el7.x86_64-advanced-8c1540fa-e2b4-407d-bcd1-59848a73e463' {
menuentry 'CentOS Linux (0-rescue-b30d0f2110ac3807b210c19ede3ce88f) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-b30d0f2110ac3807b210c19ede3ce88f-advanced-8c1540fa-e2b4-407d-bcd1-59848a73e463' {
6. 设置默认启动的内核为最新安装的内核版本并验证是否成功
[root@aws-172-20-20-101 deploy]# grub2-set-default 'CentOS Linux (4.4.180-2.el7.elrepo.x86_64) 7 (Core)’
# 查看当前默认启动内核版本
[root@aws-172-20-20-101 deploy]# grub2-editenv list
saved_entry=CentOS Linux (4.4.180-2.el7.elrepo.x86_64) 7 (Core)
7. 重启机器查看是否升级内核成功
[root@aws-172-20-20-101 deploy]# reboot
###
[root@aws-172-20-20-101 ~]# uname -r
4.4.180-2.el7.elrepo.x86_64
网友评论