阿里云centos7升级内核到4.17过程

docker对内核的支持要求很高,详情可以看:https://www.szyhf.org/2017/01/07/%E9%98%BF%E9%87%8C%E4%BA%91%E4%B8%8Ecentos%E5%86%85%E6%A0%B8%E9%97%AE%E9%A2%98/#comment-54 。文中也有阿里云容器的工程师亲自回复的升级内核的方法,不过他那套是升级内核到4.4,现在已经是4.17了,这里写一下如何升级到最新内核的过程。

而阿里云默认的centos7的内核是3.10的,如图:
paradin

首先,安装elrepo的yum源,命令如下:

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

其次是安装最新的内核,命令是yum -y --enablerepo=elrepo-kernel install kernel-ml,如果是要安装长期支持的内核,命令是yum –enablerepo=elrepo-kernel -y install kernel-lt,在一顿噼里啪啦之后,就会出现如下的字样,提示我们已经安装了4.17的kernel内核了:

1
2
3
4
5
6
7
8
9
10
11
12
Downloading packages:
kernel-ml-4.17.0-1.el7.elrepo.x86_64.rpm | 45 MB 00:00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : kernel-ml-4.17.0-1.el7.elrepo.x86_64 1/1
Verifying : kernel-ml-4.17.0-1.el7.elrepo.x86_64 1/1
Installed:
kernel-ml.x86_64 0:4.17.0-1.el7.elrepo
Complete!

centos7内核升级完毕后,还需要我们修改内核的启动顺序,vim /etc/default/grub,修改一处地方:

1
2
3
4
5
6
7
8
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved #把这里的saved改成0
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet net.ifnames=0"
GRUB_DISABLE_RECOVERY="true"
~

接下来还需要运行grub2-mkconfig命令来重新创建内核配置,命令是grub2-mkconfig -o /boot/grub2/grub.cfg,如下:

1
2
3
4
5
6
7
8
9
10
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.17.0-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-4.17.0-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-693.2.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.2.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-f0f31005fb5a436d88e3c6cbf54e25aa
Found initrd image: /boot/initramfs-0-rescue-f0f31005fb5a436d88e3c6cbf54e25aa.img
done

执行完毕之后,回到阿里云控制台重启一下这个机器,然后查看一下内核情况:

1
2
uname -r
4.17.0-1.el7.elrepo.x86_64

akb48

-------------This article is over!Thanks for reading!-------------
感谢您请我喝咖啡!(o´ω`o)
0%