跳转到主要内容

升级centos7内核

centos7 默认的内核是3.10,最新的k8s要求4.1以上内核,下面是升级方法

# 查看内核版本
uname -r

# 建议内核源文件
mkdir -p /usr/src/kernels

# 导入安装软件包安装公钥
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

# 下载内核包
wget http://mirrors.coreix.net/elrepo-archive-archive/kernel/el7/x86_64/RPMS/kernel-ml-headers-6.9.7-1.el7.elrepo.x86_64.rpm
wget http://mirrors.coreix.net/elrepo-archive-archive/kernel/el7/x86_64/RPMS/kernel-ml-6.9.7-1.el7.elrepo.x86_64.rpm
wget http://mirrors.coreix.net/elrepo-archive-archive/kernel/el7/x86_64/RPMS/kernel-ml-devel-6.9.7-1.el7.elrepo.x86_64.rpm


# 镜像加速下载

wget qq829.cn/uploads/software/kernel/6.9.7/kernel-ml-headers-6.9.7-1.el7.elrepo.x86_64.rpm
wget qq829.cn/uploads/software/kernel/6.9.7/kernel-ml-6.9.7-1.el7.elrepo.x86_64.rpm
wget qq829.cn/uploads/software/kernel/6.9.7/kernel-ml-devel-6.9.7-1.el7.elrepo.x86_64.rpm


# 安装内核包
rpm -ih kernel-ml-6.9.7-1.el7.elrepo.x86_64.rpm

rpm -ih kernel-ml-devel-6.9.7-1.el7.elrepo.x86_64.rpm

rpm -ih kernel-ml-headers-6.9.7-1.el7.elrepo.x86_64.rpm



# 查看启动信息
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg

# 设置默认启动
grub2-set-default 0

# 写入启动信息
grub2-mkconfig -o /boot/grub2/grub.cfg


# 安装  kernel-ml-headers-6.9.7-1.el7.elrepo.x86_64.rpm 报错
# 
# error: Failed dependencies:
# 	kernel-headers < 6.9.7-1.el7.elrepo conflicts with kernel-ml-headers-6.9.7-1.el7.elrepo.x86_64
# 先重启到最新的内核,卸载旧内核,再安装
# yum remove kernel-headers
# rpm -ih kernel-ml-headers-6.9.7-1.el7.elrepo.x86_64.rpm