k8s node update kernel

本文centos 7.8为例

1、无公网、无内部yum源更新内核

1.1 需要访问以下地址,下载elrepo源的kernel rpm包

http://elrepo.org/linux/kernel
http://mirrors.tuna.tsinghua.edu.cn/elrepo/kernel/

1.2 执行以下脚本安装

cat local-update-kernel-lt-5.4.sh
#!/bin/bash

# 通常安装以下两个包即可
yum install -y ./kernel-lt-5.4.104-1.el7.elrepo.x86_64.rpm ./kernel-lt-devel-5.4.104-1.el7.elrepo.x86_64.rpm

echo ""
grep "menuentry " /boot/grub2/grub.cfg

echo ""
grub2-set-default 'CentOS Linux (5.4.104-1.el7.elrepo.x86_64) 7 (Core)'

echo ""
grub2-mkconfig -o /etc/grub2.cfg

echo ""
grub2-editenv list

1.3 重启server

2、配置rpm源安装,更新内核

2.1 elrepo官方源配置

cat elrepo.reop
### Name: ELRepo.org Community Enterprise Linux Repository for el7
### URL: https://elrepo.org/

[elrepo]
name=ELRepo.org Community Enterprise Linux Repository - el7
baseurl=http://elrepo.org/linux/elrepo/el7/$basearch/
        http://mirrors.coreix.net/elrepo/elrepo/el7/$basearch/
        http://mirror.rackspace.com/elrepo/elrepo/el7/$basearch/
        http://linux-mirrors.fnal.gov/linux/elrepo/elrepo/el7/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo.el7
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0

[elrepo-testing]
name=ELRepo.org Community Enterprise Linux Testing Repository - el7
baseurl=http://elrepo.org/linux/testing/el7/$basearch/
        http://mirrors.coreix.net/elrepo/testing/el7/$basearch/
        http://mirror.rackspace.com/elrepo/testing/el7/$basearch/
        http://linux-mirrors.fnal.gov/linux/elrepo/testing/el7/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-testing.el7
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0

[elrepo-kernel]
name=ELRepo.org Community Enterprise Linux Kernel Repository - el7
baseurl=http://elrepo.org/linux/kernel/el7/$basearch/
        http://mirrors.coreix.net/elrepo/kernel/el7/$basearch/
        http://mirror.rackspace.com/elrepo/kernel/el7/$basearch/
        http://linux-mirrors.fnal.gov/linux/elrepo/kernel/el7/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-kernel.el7
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0

[elrepo-extras]
name=ELRepo.org Community Enterprise Linux Extras Repository - el7
baseurl=http://elrepo.org/linux/extras/el7/$basearch/
        http://mirrors.coreix.net/elrepo/extras/el7/$basearch/
        http://mirror.rackspace.com/elrepo/extras/el7/$basearch/
        http://linux-mirrors.fnal.gov/linux/elrepo/extras/el7/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-extras.el7
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0

2.2 国内清华源配置

cat elrepo-tsinghua.repo
[elrepo]
name=ELRepo.org Community Enterprise Linux Repository - el7
baseurl=http://mirrors.tuna.tsinghua.edu.cn/elrepo/elrepo/el7/$basearch/
        http://mirrors.coreix.net/elrepo/elrepo/el7/$basearch/
        http://mirror.rackspace.com/elrepo/elrepo/el7/$basearch/
        http://linux-mirrors.fnal.gov/linux/elrepo/elrepo/el7/$basearch/

enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0

[elrepo-testing]
name=ELRepo.org Community Enterprise Linux Testing Repository - el7
baseurl=http://mirrors.tuna.tsinghua.edu.cn/elrepo/testing/el7/$basearch/
        http://mirrors.coreix.net/elrepo/testing/el7/$basearch/
        http://mirror.rackspace.com/elrepo/testing/el7/$basearch/
        http://linux-mirrors.fnal.gov/linux/elrepo/testing/el7/$basearch/

enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0

[elrepo-kernel]
name=ELRepo.org Community Enterprise Linux Kernel Repository - el7
baseurl=http://mirrors.tuna.tsinghua.edu.cn/elrepo/kernel/el7/$basearch/
        http://mirrors.coreix.net/elrepo/kernel/el7/$basearch/
        http://mirror.rackspace.com/elrepo/kernel/el7/$basearch/
        http://linux-mirrors.fnal.gov/linux/elrepo/kernel/el7/$basearch/

enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0

[elrepo-extras]
name=ELRepo.org Community Enterprise Linux Extras Repository - el7
baseurl=http://mirrors.tuna.tsinghua.edu.cn/elrepo/extras/el7/$basearch/
        http://mirrors.coreix.net/elrepo/extras/el7/$basearch/
        http://mirror.rackspace.com/elrepo/extras/el7/$basearch/
        http://linux-mirrors.fnal.gov/linux/elrepo/extras/el7/$basearch/

enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0

2.3、更新内核

lt:长期支持

[root@test elrepo-kernel-update]# cat update-kernel-lt-5.4.sh
#!/bin/bash

# 为了方便关闭了yum gpgcheck
\cp elrepo-navinfo.repo  /etc/yum.repos.d/
yum makecache

# 通常安装以下两个包即可
yum install -y kernel-lt kernel-lt-devel


grep "menuentry " /boot/grub2/grub.cfg

# 这里的kernel版本以实际安装为准
grub2-set-default 'CentOS Linux (5.4.104-1.el7.elrepo.x86_64) 7 (Core)'

grub2-mkconfig -o /etc/grub2.cfg

grub2-editenv list

ml:主线版本,短期支持

[root@test elrepo-kernel-update]# cat update-kernel-ml-5.11.sh
#!/bin/bash

yum remove -y kernel-tools-libs kernel-tools kernel-headers

yum install -y kernel-ml kernel-ml-devel kernel-ml-doc kernel-ml-headers kernel-ml-tools kernel-ml-tools-libs kernel-ml-tools-libs-devel

yum install -y glibc-headers  sg3_utils-devel


grep "menuentry " /boot/grub2/grub.cfg

# 以下kernel版本以实际安装为准
grub2-set-default 'CentOS Linux (5.11.5-1.el7.elrepo.x86_64) 7 (Core)'
grub2-editenv list

grub2-mkconfig -o /etc/grub2.cfg
posted @ 2021-07-06 15:42  nineep  阅读(68)  评论(0编辑  收藏  举报