CentOS7 内核升级

  • A+
所属分类:网络技术

内核版本说明:

版本性质:主分支ml(mainline),稳定版(stable),长期维护lt(longterm)

版本命名格式:“A.B.C"

A代表内核版本号

B代表内核主版本号

C代表内核次版本号

1、内核升级

检查内核版本:

[root@ZabbixServer ~]# uname -r                
3.10.0-1062.12.1.el7.x86_64
[root@ZabbixServer ~]# cat /etc/redhat-release      
CentOS Linux release 7.8.2003 (Core)
[root@ZabbixServer ~]# 

在开始升级内核之前,我们先导入elrepo的key,然后在安装elrepo Yum源:

rpm -import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org ###key
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm   ###yum源

导入完成之后我们就可以查看可用的内核升级包了:

[root@ZabbixServer ~]# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * elrepo-kernel: mirrors.tuna.tsinghua.edu.cn
Available Packages
kernel-lt.x86_64                                                                  4.4.226-1.el7.elrepo                                                  elrepo-kernel
kernel-lt-devel.x86_64                                                            4.4.226-1.el7.elrepo                                                  elrepo-kernel
kernel-lt-doc.noarch                                                              4.4.226-1.el7.elrepo                                                  elrepo-kernel
kernel-lt-headers.x86_64                                                          4.4.226-1.el7.elrepo                                                  elrepo-kernel
kernel-lt-tools.x86_64                                                            4.4.226-1.el7.elrepo                                                  elrepo-kernel
kernel-lt-tools-libs.x86_64                                                       4.4.226-1.el7.elrepo                                                  elrepo-kernel
kernel-lt-tools-libs-devel.x86_64                                                 4.4.226-1.el7.elrepo                                                  elrepo-kernel
kernel-ml-doc.noarch                                                              5.7.1-1.el7.elrepo                                                    elrepo-kernel
kernel-ml-headers.x86_64                                                          5.7.1-1.el7.elrepo                                                    elrepo-kernel
kernel-ml-tools.x86_64                                                            5.7.1-1.el7.elrepo                                                    elrepo-kernel
kernel-ml-tools-libs.x86_64                                                       5.7.1-1.el7.elrepo                                                    elrepo-kernel
kernel-ml-tools-libs-devel.x86_64                                                 5.7.1-1.el7.elrepo                                                    elrepo-kernel
perf.x86_64                                                                       5.7.1-1.el7.elrepo                                                    elrepo-kernel
python-perf.x86_64                                                                5.7.1-1.el7.elrepo                                                    elrepo-kernel
[root@ZabbixServer ~]# 

我们使用下面的命令升级内核:

yum -y --enablerepo=elrepo-kernel install kernel-ml.x86_64 kernel-ml-devel.x86_64

 

2、修改Grub

内核升级完成之后,我们还需要调整内核启动顺序;通过下面的命令我们可以看到当前系统的升级内核启动顺序为0:

[root@ZabbixServer ~]#  awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg
CentOS Linux (5.7.1-1.el7.elrepo.x86_64) 7 (Core)
CentOS Linux (3.10.0-1127.10.1.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-1062.12.1.el7.x86_64) 7 (Core)
CentOS Linux (3.10.0-514.el7.x86_64) 7 (Core)
CentOS Linux (0-rescue-7f6e775eed554e339f375d1cdebe53d4) 7 (Core)
[root@ZabbixServer ~]# 

我们需要修改内核的启动顺序为0,让系统启动的时候默认去启动刚才升级的系统内核:

[root@ZabbixServer ~]# vi /etc/default/grub  
[root@ZabbixServer ~]# cat /etc/default/grub 
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=0
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
[root@ZabbixServer ~]# 

修改完成以后我们用 grub2-mkconfig -o /boot/grub2/grub.cfg 命令来创建内核配置:

[root@ZabbixServer ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.7.1-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-5.7.1-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1127.10.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1127.10.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1062.12.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1062.12.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-514.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-514.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-7f6e775eed554e339f375d1cdebe53d4
Found initrd image: /boot/initramfs-0-rescue-7f6e775eed554e339f375d1cdebe53d4.img
done
[root@ZabbixServer ~]# 

然后我们reboot重启主机,通过uname -r命令验证一下当前系统内核版本:

[root@ZabbixServer ~]# uname -r
5.7.1-1.el7.elrepo.x86_64
[root@ZabbixServer ~]# cat /etc/redhat-release 
CentOS Linux release 7.8.2003 (Core)
[root@ZabbixServer ~]# 
  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin
avatar

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: