centos7内核升级方法

avatar 2023年3月10日18:22:35 评论 194 次浏览

今天在安装kubernetes的时候,什么都安装好了,但是在安装jenkins的时候提示一直安装不上去,后来发现原来pod中无法域名解析,主要原因是因为我的系统内核版本太低了,这里就记录一下升级内核的方法。

 [root@www.wulaoer.org ~]# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
 [root@www.wulaoer.org ~]# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
 Retrieving http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm
 Preparing...                          ################################# [100%]
 Updating / installing...
    1:elrepo-release-7.0-3.el7.elrepo  ################################# [100%]

ELRepo 仓库是基于社区的用于企业级 Linux 仓库,提供对 RedHat Enterprise (RHEL) 和 其他基于 RHEL的 Linux 发行版(CentOS、Scientific、Fedora 等)的支持。

 [root@www.wulaoer.org ~]# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
 查看可以使用的版本
 其中lt表示long-term,即主线版本,该版本建议慎重选择。
 其中mt表示latest mainline,即长期稳定版本,稳定可靠,建议安装该版本
 [root@node2 ~]# yum -y --enablerepo=elrepo-kernel install kernel-lt
 Loaded plugins: fastestmirror
 Loading mirror speeds from cached hostfile

选择最新版安装,安装后需要修改grub2,也就是系统默认启动项,然后进行重启即可。

[root@www.wulaoer.org ~]# sudo awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
0 : CentOS Linux (5.4.234-1.el7.elrepo.x86_64) 7 (Core)
1 : CentOS Linux (3.10.0-1160.83.1.el7.x86_64) 7 (Core)
2 : CentOS Linux (3.10.0-1160.45.1.el7.x86_64) 7 (Core)
3 : CentOS Linux (0-rescue-754f8a1ad2654504b10cacfb2e9d5eb0) 7 (Core)
[root@www.wulaoer.org ~]# grub2-set-default 0
[root@www.wulaoer.org ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.234-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-5.4.234-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.83.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.83.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.45.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.45.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-754f8a1ad2654504b10cacfb2e9d5eb0
Found initrd image: /boot/initramfs-0-rescue-754f8a1ad2654504b10cacfb2e9d5eb0.img
done
## 设置开机从新内核启动
[root@www.wulaoer.org ~]# grub2-set-default "CentOS Linux (5.4.234-1.el7.elrepo.x86_64) 7 (Core)"

## 查看内核启动项
[root@www.wulaoer.org ~]# grub2-editenv list
saved_entry=CentOS Linux (5.4.234-1.el7.elrepo.x86_64) 7 (Core)

重启之后,在查看一下版本

 [root@master1 ~]# uname -r
 5.4.234-1.el7.elrepo.x86_64
avatar

发表评论

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