最近折腾多架构镜像打包的时候2个环境一直报错 Cannot write to /proc/sys/fs/binfmt_misc/register: write /proc/sys/fs/binfmt_misc/register: invalid argument ,差点放弃折腾。后来发现有1台可以成功运行binfmt_misc相关的命令,看了一下,3台环境各不相同,仔细想了想,应该是内核版本不同导致,验证方法很简单,vps上跑了一个bbr修改的脚本,升级了内核另外2台就好用了。
然后又找到了这2篇文章 https://github.com/docker/buildx
和 https://nexus.eddiesinentropy.net/2020/01/12/Building-Multi-architecture-Docker-Images-With-Buildx/ ,
里面明确提到除开docker >=19.03外 ,系统内核需要大于4.8,所以这里记录一下正常途径升级内核的过程。
- 查看当前版本
1 2 |
uname –msr</code> 发现测试环境真的够老,必须马上升<code class="language-output" data-lang="output"> Linux 3.10.0-1062.9.1.el7.x86_64 x86_64 |
- 更新centos 源 CentOS Repositories
1 |
yum –y update |
启用 ELRepo Repository库
1 |
rpm –-import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org |
1 |
rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm |
1 2 3 4 5 6 7 8 |
rpm -Uvh https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm 获取https://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm 准备中... ################################# [100%] 正在升级/安装... 1:elrepo-release-7.0-3.el7.elrepo ################################# [100%] |
- 列出当前可用内核
1 |
yum list available --disablerepo='*' --enablerepo=elrepo-kernel</code> 其中 lt 是长期支持稳定版 , ml是主线发布版,要满足》4.8,看来只能选择5.7.9了 |
[root@dcs-s1 ~]# yum list available --disablerepo='*' --enablerepo=elrepo-kernel
已加载插件:fastestmirror, product-id, search-disabled-repos, subscription-manager, versionlock
This system is not registered with an entitlement server. You can use subscription-manager to register.
Determining fastest mirrors
* elrepo-kernel: hkg.mirror.rackspace.com
elrepo-kernel | 2.9 kB 00:00:00
elrepo-kernel/primary_db | 1.9 MB 00:00:02
可安装的软件包
elrepo-release.noarch 7.0-5.el7.elrepo elrepo-kernel
kernel-lt.x86_64 4.4.230-1.el7.elrepo elrepo-kernel
kernel-lt-devel.x86_64 4.4.230-1.el7.elrepo elrepo-kernel
kernel-lt-doc.noarch 4.4.230-1.el7.elrepo elrepo-kernel
kernel-lt-headers.x86_64 4.4.230-1.el7.elrepo elrepo-kernel
kernel-lt-tools.x86_64 4.4.230-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs.x86_64 4.4.230-1.el7.elrepo elrepo-kernel
kernel-lt-tools-libs-devel.x86_64 4.4.230-1.el7.elrepo elrepo-kernel
kernel-ml.x86_64 5.7.9-1.el7.elrepo elrepo-kernel
kernel-ml-devel.x86_64 5.7.9-1.el7.elrepo elrepo-kernel
kernel-ml-doc.noarch 5.7.9-1.el7.elrepo elrepo-kernel
kernel-ml-headers.x86_64 5.7.9-1.el7.elrepo elrepo-kernel
kernel-ml-tools.x86_64 5.7.9-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs.x86_64 5.7.9-1.el7.elrepo elrepo-kernel
kernel-ml-tools-libs-devel.x86_64 5.7.9-1.el7.elrepo elrepo-kernel
perf.x86_64 5.7.9-1.el7.elrepo elrepo-kernel
python-perf.x86_64 5.7.9-1.el7.elrepo elrepo-kernel
- 重启启用新内核
reboot
vm管理页面选择一下新内核,启动
- 修改默认启动内核
1 |
vim /etc/default/grub |
GRUB_DEFAULT=saved 修改为 GRUB_DEFAULT=0 #(也就是零,第一个启动项)保存。
- 重建内核设置
grub2-mkconfig -o /boot/grub2/grub.cfg
出现如下提示
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.7.9-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-5.7.9-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1127.10.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1127.10.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-862.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-862.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-0f84e1aa540c44d0b0df909e9bbf3722
Found initrd image: /boot/initramfs-0-rescue-0f84e1aa540c44d0b0df909e9bbf3722.img
done
重启系统 reboot 生效
开机后再次检查 内核 uname –msr
Linux 5.7.9-1.el7.elrepo.x86_64 x86_64 升级成功
- 可能报错,
- 开机有一些报错日志,似乎不影响使用,以后再查。
[三 7月 22 09:10:53 2020] oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=07ee5f572476e7a9c2ab1cfcc86d3bb628f450a83143549664b4d889e3ab2850,mems_allowed=0,oom_memcg=/kubepods/podc493397f-b457-11ea-9aff-0242ac120005,task_memcg=/kubepods/podc493397f-b457-11ea-9aff-0242ac120005/07ee5f572476e7a9c2ab1cfcc86d3bb628f450a83143549664b4d889e3ab2850,task=python,pid=9873,uid=0
[三 7月 22 09:10:53 2020] Memory cgroup out of memory: Killed process 9873 (python) total-vm:106568kB, anon-rss:23756kB, file-rss:0kB, shmem-rss:0kB, UID:0 pgtables:220kB oom_score_adj:-998
[三 7月 22 09:10:53 2020] oom_reaper: reaped process 9873 (python), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
[三 7月 22 09:10:55 2020] python invoked oom-killer: gfp_mask=0xc40(GFP_NOFS), order=0, oom_score_adj=-998
[三 7月 22 09:10:55 2020] CPU: 2 PID: 8555 Comm: python Not tainted 5.7.9-1.el7.elrepo.x86_64 #1
....
[三 7月 22 09:10:55 2020] oom-kill:constraint=CONSTRAINT_MEMCG,nodemask=(null),cpuset=07ee5f572476e7a9c2ab1cfcc86d3bb628f450a83143549664b4d889e3ab2850,mems_allowed=0,oom_memcg=/kubepods/podc493397f-b457-11ea-9aff-0242ac120005,task_memcg=/kubepods/podc493397f-b457-11ea-9aff-0242ac120005/07ee5f572476e7a9c2ab1cfcc86d3bb628f450a83143549664b4d889e3ab2850,task=python,pid=9872,uid=0
[三 7月 22 09:10:55 2020] Memory cgroup out of memory: Killed process 9872 (python) total-vm:106588kB, anon-rss:23800kB, file-rss:0kB, shmem-rss:0kB, UID:0 pgtables:220kB oom_score_adj:-998
[三 7月 22 09:10:55 2020] oom_reaper: reaped process 9872 (python), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
参考
https://phoenixnap.com/kb/how-to-upgrade-kernel-centos
https://nexus.eddiesinentropy.net/2020/01/12/Building-Multi-architecture-Docker-Images-With-Buildx/
文章评论