centos7.5更新内核到4.18稳定版

centos7.5更新内核到4.18

Docker对Linux内核版本的最低要求是3.10。目前Linux内核已经发布到 4.18,为了更好使用docker和k8s,需要对公司相关CentOS 7内核进行升级。

docker官方对内核的说明:
https://docs.docker.com/storage/storagedriver/overlayfs-driver/
Docker存储驱动说明,overlay可以使用但不建议,最好使用overlay2,内核需要4.0以上,或者CentOS7的内核在3.10.0-514以上,需要额外的设置参数,禁止检测内核为4.0版本。
If you use OverlayFS, use the overlay2 driver rather than the overlay driver, because it is more efficient in terms of inode utilization. To use the new driver, you need version 4.0 or higher of the Linux kernel, unless you are a Docker EE user on RHEL or CentOS, in which case you need version 3.10.0-514 or higher of the kernel and to follow some extra steps.

对Docker EE 17.06.02-ee5 and 17.06.02-ee6,CentOS7的内核在3.10.0-514以上,需要额外的设置参数,禁止检测内核为4.0版本。
Note: RHEL and CentOS users on Docker EE 17.06.02-ee5 and 17.06.02-ee6
You need to add a second option to the daemon.json to disable the check for version 4.0 or higher of the Linux kernel. Your daemon.json should look like the following. This is only needed for Docker EE users of RHEL or CentOS. Do not attempt to use overlay2 with kernel versions older than 3.10.0-514.

下载公钥

# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

安装elrepo repo

rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm

仓库启用后,列出可用的内核相关包:

yum --disablerepo="*" --enablerepo="elrepo-kernel" list available 

查询所有kernel包

rpm -qa|grep kernel
kernel-devel-3.10.0-862.6.3.el7.x86_64
kernel-tools-libs-3.10.0-862.6.3.el7.x86_64
kernel-tools-3.10.0-862.6.3.el7.x86_64
kernel-devel-3.10.0-862.el7.x86_64
abrt-addon-kerneloops-2.1.11-50.el7.centos.x86_64
kernel-3.10.0-862.6.3.el7.x86_64
kernel-headers-3.10.0-862.6.3.el7.x86_64

根据上述查询结果,删除所有旧内核相关包

yum remove kernel-devel kernel-tools-libs kernel-tools kernel-headers

卸载上述软件包会连带卸载以下安装包需要更新后,重新安装。kernel-devel会连带删除systemtap和systemtap-devel。kernel-headers则和下面都有关系。

compat-glibc   x86_64   1:2.12-4.el7.centos
compat-glibc-headers  x86_64   1:2.12-4.el7.centos
gcc x86_64   4.8.5-28.el7_5.1
gcc-c++x86_64   4.8.5-28.el7_5.1
gcc-gfortran   x86_64   4.8.5-28.el7_5.1
glibc-develx86_64   2.17-222.el7
glibc-headers  x86_64   2.17-222.el7
libquadmath-devel  x86_64   4.8.5-28.el7_5.1
libtool x86_64   2.4.2-22.el7_3
systemtap   x86_64   3.2-8.el7_5
systemtap-develx86_64   3.2-8.el7_5

安装新内核

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

安装新内核相关软件

yum --disablerepo=\* --enablerepo=elrepo-kernel install -y  kernel-ml-devel kernel-ml-tools kernel-ml-tools-libs kernel-ml-tools-libs-devel kernel-ml-headers

查看默认内核

grub2-editenv list

将新内核设为默认grbu启动项

grub2-set-default 0

生成 grub 配置文件

grub2-mkconfig -o /etc/grub2.cfg
reboot   #不重启也可以

删除旧内核

yum remove kernel-3.10.0-862.6.3.el7.x86_64

安装更新旧内核时被卸载的软件

yum install -y compat-glibc compat-glibc-headers gcc gcc-c++ gcc-gfortran glibc-devel glibc-headers libquadmath-devel libtool systemtap systemtap-devel

查看默认内核

grub2-editenv list
saved_entry=CentOS Linux (4.18.11-1.el7.elrepo.x86_64) 7 (Core)
posted @ 2018-10-02 13:26  iwalkman  阅读(9929)  评论(0编辑  收藏  举报