centos7.4升级内核3.x到4.x,使用yum安装的方式

1、centos版本

[root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core)

2、导入elrepo的key,然后安装elrepo的yum源

[root@localhost ~]# rpm -import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
[root@localhost ~]# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
获取http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
获取http://elrepo.org/elrepo-release-7.0-4.el7.elrepo.noarch.rpm
准备中...                          ################################# [100%]
正在升级/安装...
   1:elrepo-release-7.0-4.el7.elrepo  ################################# [100%]
   

3、列出可升级的内核

[root@localhost ~]# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
 
已加载插件:fastestmirror
elrepo-kernel                                                 | 2.9 kB  00:00:00     
elrepo-kernel/primary_db                                      | 1.9 MB  00:00:09     
Loading mirror speeds from cached hostfile
 * elrepo-kernel: mirrors.tuna.tsinghua.edu.cn
可安装的软件包
elrepo-release.noarch                     7.0-5.el7.elrepo              elrepo-kernel
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

4、如图可以看出,长期维护版本lt为4.4,最新主线稳定版ml为5.8,我们安装长期维护版本内核,使用如下命令:

[root@localhost ~]# yum -y --enablerepo=elrepo-kernel install kernel-lt.x86_64  kernel-lt-devel.x86_64 
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.bit.edu.cn
 * elrepo: mirrors.tuna.tsinghua.edu.cn

5、查看内核默认启动顺序

[root@localhost ~]# awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
CentOS Linux (4.4.232-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-61e6672250f14dc4bb5130e77f9f621b) 7 (Core)

如上,4.4版本内核目前位置为0,原来的3.10版本内核目前位置为1,所以需要修改内核启动顺序为0。centos7.4升级内核3.x到4.x,使用yum安装的方式_第1张图片

[root@localhost ~]# vim /etc/default/grub

原本的GRUB_DEFAULT=saved改为GRUB_0=saved

运行grub2-mkconfig命令来重新创建内核配置:

[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.232-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-4.4.232-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-61e6672250f14dc4bb5130e77f9f621b
Found initrd image: /boot/initramfs-0-rescue-61e6672250f14dc4bb5130e77f9f621b.img
done

6、重启

在这里插入图片描述
centos7.4升级内核3.x到4.x,使用yum安装的方式_第2张图片
可以更新一下,到此内核升级完成
centos7.4升级内核3.x到4.x,使用yum安装的方式_第3张图片

你可能感兴趣的:(linux,centos,mysql,内核)