跨cpu架构部署容器技术点:怎样修改Linux 的内核版本

简介: 在使用Docker 进行跨平台部署之后,我们还可以尝试进行跨架构部署。从X86 架构上移植到 aarch64 上。

在使用Docker 进行跨平台部署之后,我们还可以尝试进行跨架构部署。

从X86 架构上移植到 aarch64 上。

要使用这个功能,需要Docker 的版本在19以上,因为这个是19以上版本中提供的一个实验性方案。

除此之外还需要:Linux的内核版本要在4.X版本以上,

否则的话,会出现错误,特别是 centOS 用户。


这一节讲述的内容就是如何在centOS 用户中修改Linux内核。

以下是具体步骤


1. 检查当前版本

检查当前内核版本是否在4.X版本以上,如果是,请直接跳转第三步 测试DOCKER buildx[4]插件使用

是否正常


检查方式:


uname -a


实操:


[root@master ~]# uname -a
Linux master 3.10.0-1160.92.1.el7.x86_64 #1 SMP Tue Jun 20 11:48:01 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

查看方式:


查看 Linux master 之后的内容,数字是版本号,紧随其后的是cpu架构。

以上述内容为例:


版本号是 3.10.0-1160.92.1.el7 最开始的 3 是大版本号,而我们所要求的 4.x 就是指 要使用大版本号为4 的内核版本。

x86_64就是指 系统采用 x86架构 64位 计算机操作系统。

2. 升级内核版本

2.1 升级方式

本次升级,我们采用使用内核文件本地升级的方式进行操作,

具体分为六部分: 创建存放内核文件的分区(文件夹)、下载内核、安装内核、更改内核启动顺序、检查默认内核版本、重启后检查内核版本


以下为分步骤详述:


2.1.1 创建内核文件的存放地址

这里我们通常建议:采用 /opt/下存储。或者 /root/下存储,前者采用Linux 管理方式, 后者采用管理员管理方式,不建议随意存放,或者放在非管理员用户下。


这里采用 /opt/kernel目录。


mkdir -p /opt/kernel


2.1.2 下载内核

这里采用 从指定网址下载,如果你的服务器不能链接外网,后续我会把内核文件的百度网盘链接更新在此处,可以直接下载文件传输到服务器上。


cd /opt/kernel
wget
http://193.49.22.109/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-devel-4.19.12-1.el7.elrepo.x86_64.rpm
wget
http://193.49.22.109/elrepo/kernel/el7/x86_64/RPMS/kernel-ml-4.19.12-1.el7.elrepo.x86_64.rpm


2.1.3 安装内核

cd /opt/kernel && yum localinstall -y kernel-ml\*


注意:当使用关键词查找方式不能找到安装,提示Nothing to do时,可以指定位置,依次安装。


过程如下


  • 问题展示:
[root@master kernel]# cd /opt/kernel && yum localinstall -y kernel-ml\*
Loaded plugins: fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Skipping: kernel-ml*, filename does not end in .rpm.
Nothing to do


  • 实际情况
[root@master kernel]# ls
kernel-ml-4.19.12-1.el7.elrepo.x86_64.rpm  kernel-ml-devel-4.19.12-1.el7.elrepo.x86_64.rpm


  • 解决方式
[root@master kernel]# yum localinstall -y kernel-ml-4.19.12-1.el7.elrepo.x86_64.rpm


[root@master kernel]#  yum localinstall -y kernel-ml-devel-4.19.12-1.el7.elrepo.x86_64.rpm


2.1.4 更改内核启动顺序

[root@master kernel]# grub2-set-default 0 && grub2-mkconfig -o /etc/grub2.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.19.12-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-4.19.12-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.92.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.92.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.90.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.90.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.88.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.88.1.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-01c8d25d03ff48abbbe893b5100e4d2d
Found initrd image: /boot/initramfs-0-rescue-01c8d25d03ff48abbbe893b5100e4d2d.img
done


2.1.5 检查默认内核是不是 4.19

这里是因为我安装的版本是 4.19.12 如果你使用的是其他版本,请自行变更。


[root@master kernel]# grubby \--default-kernel
/boot/vmlinuz-4.19.12-1.el7.elrepo.x86_64


2.1.6 重启后检查内核版本是不是4.19

重启服务器


[root@master kernel] reboot


检查版本


[root@master ~]# uname -a
Linux master 4.19.12-1.el7.elrepo.x86_64 #1 SMP Fri Dec 21 11:06:36 EST 2018 x86_64 x86_64 x86_64 GNU/Linux


2.2 常见错误记录

在使用 4.x 以下内核的版本时,Docker 的 Bulidx[4] 插件使用时会提示报错的

其中常出现错误展示:


注意:使用账户为root


错误一

[root@master ~]# docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d
Unable to find image 'docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d' locally
66f9012c56a8316f9244ffd7622d7c21c1f6f28d: Pulling from docker/binfmt
1537944798a7: Pull complete
2e6cfc71c612: Pull complete
e4893eb1e1de: Pull complete
Digest: sha256:4f7c8d7fc9ec599be42e3d4587cb1bd9baa6e548d540cddd50fabaa7ff966041
Status: Downloaded newer image for docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d
2023/07/26 08:01:55 Cannot write to /proc/sys/fs/binfmt_misc/register: write /proc/sys/fs/binfmt_misc/register: invalid argument


错误二

[root@master ~]# docker run --rm -t arm64v8/ubuntu uname -m
Unable to find image 'arm64v8/ubuntu:latest' locally
latest: Pulling from arm64v8/ubuntu
a39c84e173f0: Pull complete
Digest: sha256:26c3bd3ae441c873a210200bcbb975ffd2bbf0c0841a4584f4476c8a5b8f3d99
Status: Downloaded newer image for arm64v8/ubuntu:latest
WARNING: The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64/v3) and no specific platform was requested exec /usr/bin/uname: exec format error


错误三

[root@master ~]# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
Unable to find image 'multiarch/qemu-user-static:latest' locally
latest: Pulling from multiarch/qemu-user-static
01c2cdc13739: Pull complete
11933eee4160: Pull complete
30abb83a18eb: Pull complete
0657daef200b: Pull complete
10094524a9f3: Pull complete
Digest: sha256:2c8b8fcf1d6badfca797c3fb46b7bb5f705ec7e66363e1cfeb7b7d4c7086e360
Status: Downloaded newer image for multiarch/qemu-user-static:latest
Setting /usr/bin/qemu-alpha-static as binfmt interpreter for alpha
sh: write error: Invalid argument
sh: write error: Invalid argument
Setting /usr/bin/qemu-arm-static as binfmt interpreter for arm
Setting /usr/bin/qemu-armeb-static as binfmt interpreter for armeb
sh: write error: Invalid argument
Setting /usr/bin/qemu-sparc-static as binfmt interpreter for sparc
sh: write error: Invalid argument
sh: write error: Invalid argument
Setting /usr/bin/qemu-sparc32plus-static as binfmt interpreter for sparc32plus
sh: write error: Invalid argument
Setting /usr/bin/qemu-sparc64-static as binfmt interpreter for sparc64
sh: write error: Invalid argument
Setting /usr/bin/qemu-ppc-static as binfmt interpreter for ppc
Setting /usr/bin/qemu-ppc64-static as binfmt interpreter for ppc64
sh: write error: Invalid argument
Setting /usr/bin/qemu-ppc64le-static as binfmt interpreter for ppc64le
sh: write error: Invalid argument
Setting /usr/bin/qemu-m68k-static as binfmt interpreter for m68k
sh: write error: Invalid argument
Setting /usr/bin/qemu-mips-static as binfmt interpreter for mips
sh: write error: Invalid argument
Setting /usr/bin/qemu-mipsel-static as binfmt interpreter for mipsel
sh: write error: Invalid argument
sh: write error: Invalid argument
Setting /usr/bin/qemu-mipsn32-static as binfmt interpreter for mipsn32
sh: write error: Invalid argument
Setting /usr/bin/qemu-mipsn32el-static as binfmt interpreter for mipsn32el
Setting /usr/bin/qemu-mips64-static as binfmt interpreter for mips64
sh: write error: Invalid argument
sh: write error: Invalid argument
Setting /usr/bin/qemu-mips64el-static as binfmt interpreter for mips64el
Setting /usr/bin/qemu-sh4-static as binfmt interpreter for sh4
sh: write error: Invalid argument
Setting /usr/bin/qemu-sh4eb-static as binfmt interpreter for sh4eb
sh: write error: Invalid argument
sh: write error: Invalid argument
Setting /usr/bin/qemu-s390x-static as binfmt interpreter for s390x
sh: write error: Invalid argument
Setting /usr/bin/qemu-aarch64-static as binfmt interpreter for aarch64
sh: write error: Invalid argument
Setting /usr/bin/qemu-aarch64_be-static as binfmt interpreter for aarch64_be
Setting /usr/bin/qemu-hppa-static as binfmt interpreter for hppa
sh: write error: Invalid argument
Setting /usr/bin/qemu-riscv32-static as binfmt interpreter for riscv32
sh: write error: Invalid argument
Setting /usr/bin/qemu-riscv64-static as binfmt interpreter for riscv64
sh: write error: Invalid argument
Setting /usr/bin/qemu-xtensa-static as binfmt interpreter for xtensa
sh: write error: Invalid argument
Setting /usr/bin/qemu-xtensaeb-static as binfmt interpreter for xtensaeb
sh: write error: Invalid argument
Setting /usr/bin/qemu-microblaze-static as binfmt interpreter for microblaze
sh: write error: Invalid argument
Setting /usr/bin/qemu-microblazeel-static as binfmt interpreter for microblazeel
sh: write error: Invalid argument
Setting /usr/bin/qemu-or1k-static as binfmt interpreter for or1k
sh: write error: Invalid argument
Setting /usr/bin/qemu-hexagon-static as binfmt interpreter for hexagon
sh: write error: Invalid argument

3. 测试Docker 的**buildx[4]**插件使用是否正常

[root@master ~]# docker buildx ls 
NAME/NODE    DRIVER/ENDPOINT             STATUS         PLATFORMS
mybuilder *  docker-container            mybuilder0       unix:///var/run/docker.sock running linux/amd64, linux/arm64, linux/ppc64le, linux/s390x, linux/386, linux/arm/v7, linux/arm/v6
default      docker
  default    default                     running linux/amd64, linux/386


无告警和报错内容,正常使用。


4. 总结

至此,完成更改。

目录
相关文章
|
4月前
|
存储 缓存 安全
某鱼电商接口架构深度剖析:从稳定性到高性能的技术密码
某鱼电商接口架构揭秘:分层解耦、安全加固、性能优化三维设计,实现200ms内响应、故障率低于0.1%。详解三层架构、多引擎存储、异步发布、WebSocket通信与全链路防护,助力开发者突破电商接口“三难”困境。
|
5月前
|
数据采集 监控 JavaScript
移动端性能监控探索:鸿蒙 NEXT 探针架构与技术实现
阿里云 ARMS 团队倾力打造的鸿蒙 NEXT SDK,为鸿蒙应用提供了业界领先的全链路监控解决方案。这不仅仅是一个 SDK,更是您洞察用户体验、优化应用性能的智能伙伴。
719 44
|
4月前
|
人工智能 自然语言处理 安全
AI助教系统:基于大模型与智能体架构的新一代教育技术引擎
AI助教系统融合大语言模型、教育知识图谱、多模态交互与智能体架构,实现精准学情诊断、个性化辅导与主动教学。支持图文语音输入,本地化部署保障隐私,重构“教、学、评、辅”全链路,推动因材施教落地,助力教育数字化转型。(238字)
800 23
|
4月前
|
Java Linux 虚拟化
【Docker】(1)Docker的概述与架构,手把手带你安装Docker,云原生路上不可缺少的一门技术!
1. Docker简介 1.1 Docker是什么 为什么docker会出现? 假定您在开发一款平台项目,您的开发环境具有特定的配置。其他开发人员身处的环境配置也各有不同。 您正在开发的应用依赖于您当前的配置且还要依赖于某些配置文件。 您的企业还拥有标准化的测试和生产环境,且具有自身的配置和一系列支持文件。 **要求:**希望尽可能多在本地模拟这些环境而不产生重新创建服务器环境的开销 问题: 要如何确保应用能够在这些环境中运行和通过质量检测? 在部署过程中不出现令人头疼的版本、配置问题 无需重新编写代码和进行故障修复
439 2
|
5月前
|
Cloud Native API 开发者
Gemini 2.5 Flash 技术拆解:从 MoE 架构到阿里云生态落地指南
2025年9月,谷歌Gemini 2.5 Flash发布,性能提升5%、成本降24%,引发行业关注。其MoE架构、百万上下文与“思考”范式,助力阿里云开发者高效构建云原生应用。本文解析技术内核,结合汽车、物流等案例,提供落地指南与避坑建议,展望大模型与流计算融合前景。
662 6
|
4月前
|
存储 监控 安全
132_API部署:FastAPI与现代安全架构深度解析与LLM服务化最佳实践
在大语言模型(LLM)部署的最后一公里,API接口的设计与安全性直接决定了模型服务的可用性、稳定性与用户信任度。随着2025年LLM应用的爆炸式增长,如何构建高性能、高安全性的REST API成为开发者面临的核心挑战。FastAPI作为Python生态中最受青睐的Web框架之一,凭借其卓越的性能、强大的类型安全支持和完善的文档生成能力,已成为LLM服务化部署的首选方案。
|
6月前
|
机器学习/深度学习 存储 人工智能
RAG系统文本检索优化:Cross-Encoder与Bi-Encoder架构技术对比与选择指南
本文将深入分析这两种编码架构的技术原理、数学基础、实现流程以及各自的优势与局限性,并探讨混合架构的应用策略。
457 10
RAG系统文本检索优化:Cross-Encoder与Bi-Encoder架构技术对比与选择指南
|
4月前
|
存储 人工智能 搜索推荐
拔俗AI助教系统:基于大模型与智能体架构的新一代教育技术引擎
AI助教融合大语言模型、教育知识图谱、多模态感知与智能体技术,重构“教、学、评、辅”全链路。通过微调LLM、精准诊断错因、多模态交互与自主任务规划,实现个性化教学。轻量化部署与隐私保护设计保障落地安全,未来将向情感感知与教育深度协同演进。(238字)
471 0