CentOS7.6升级内核
LiuSw Lv6

CentOS7.6升级内核

1、更新系统和安装包

1
2
3
4
yum -y update

# 安装yum插件,以在安装和更新软件包时更快
yum -y install yum-plugin-fastestmirror

2、查看内核版本

1
uname -r

3、添加ELrepo存储库

(在安装新的内核版本之前,我们需要添加一个新的存储 库-ELRepo存储库)
将ELRepo gpg密钥添加到系统

1
2
3
4
5
# 使用rpm命令添加新的ELRepo存储库
rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

# 检查系统上启用的所有存储库,并确保ELRepo在列表中、
yum repolist

4、安装最新版本的内核

在线升级

(从ELRepo信息库安装一个新的最新内核)

1
2
yum --enablerepo=elrepo-kernel install kernel-ml
# --enablerepo是在CentOS系统上启用特定存储库的选项。默认情况下,启 用“ elrepo”存储库,但不启用“ elrepo-kernel”存储库

离线升级

1.用可以联网的机器下载升级包

1
2
3
yum install yum-plugin-downloadonly
# 下载kernel-ml 包
yum install --enablerepo=elrepo-kernel --downloadonly --downloaddir=./ kernel-ml

2.将rpm包上传到要升级的服务器

1
rpm -ivh 下载的内核升级的rpm包名称

5、在centos7上配置Grub2

使用以下awk命令检查Grub2中所有可用的内核版本

1
2
3
4
5
6
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg

# 0 : CentOS Linux (5.16.0-1.el7.elrepo.x86_64) 7 (Core)
# 1 : CentOS Linux (3.10.0-1160.49.1.el7.x86_64) 7 (Core)
# 2 : CentOS Linux (3.10.0-957.el7.x86_64) 7 (Core)
# 3 : CentOS Linux (0-rescue-6ae14471c6f9480298cc7690f9d1803e) 7 (Core)

(可以看到有两个版本的内核3.10.0和5.6.7)

6、配置系统默认内核5.6.7

1
grub2-set-default 0

使用“ gurb2-mkconfig”命令生成grub2配置,然后重新启动服务器

1
grub2-mkconfig -o /boot/grub2/grub.cfg

7、 重启查看内核版本

1
2
reboot
uname -r
 评论