跨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. 总结

至此,完成更改。

目录
相关文章
|
2月前
|
Kubernetes Cloud Native 微服务
探索云原生技术:容器化与微服务架构的融合之旅
本文将带领读者深入了解云原生技术的核心概念,特别是容器化和微服务架构如何相辅相成,共同构建现代软件系统。我们将通过实际代码示例,探讨如何在云平台上部署和管理微服务,以及如何使用容器编排工具来自动化这一过程。文章旨在为开发者和技术决策者提供实用的指导,帮助他们在云原生时代中更好地设计、部署和维护应用。
|
25天前
|
应用服务中间件 Linux nginx
【Azure App Service】基于Linux创建的App Service是否可以主动升级内置的Nginx版本呢?
基于Linux创建的App Service是否可以主动升级内置的Nginx版本呢?Web App Linux 默认使用的 Nginx 版本是由平台预定义的,无法更改这个版本。
134 77
|
1天前
【YashanDB 知识库】如何排查 YMP 报错:”OCI 版本为空或 OCI 的架构和本地系统的架构不符“
在迁移预检查的版本检查阶段报错“OCI 版本为空”,原因是 OCI 架构与本地系统不符或依赖库缺失。排查发现 `libdrv_oracle.so` 缺少 `libnsl.so.1` 库,尽管 OCI 客户端路径已正确加入 `LD_LIBRARY_PATH`。解决方法包括下载安装相应动态库版本,或通过软链接指向更高版本库(如 `libnsl.so.2`)。总结:确保动态库路径正确配置,并使用 `ldd` 查看依赖库,必要时创建软链接以解决问题。
|
1月前
|
安全 Linux 测试技术
Intel Linux 内核测试套件-LKVS介绍 | 龙蜥大讲堂104期
《Intel Linux内核测试套件-LKVS介绍》(龙蜥大讲堂104期)主要介绍了LKVS的定义、使用方法、测试范围、典型案例及其优势。LKVS是轻量级、低耦合且高代码覆盖率的测试工具,涵盖20多个硬件和内核属性,已开源并集成到多个社区CICD系统中。课程详细讲解了如何使用LKVS进行CPU、电源管理和安全特性(如TDX、CET)的测试,并展示了其在实际应用中的价值。
|
1月前
|
Ubuntu Linux 开发者
Ubuntu20.04搭建嵌入式linux网络加载内核、设备树和根文件系统
使用上述U-Boot命令配置并启动嵌入式设备。如果配置正确,设备将通过TFTP加载内核和设备树,并通过NFS挂载根文件系统。
114 15
|
2月前
|
Unix Linux Docker
CentOS停更沉寂,RHEL巨变限制源代:Docker容器化技术的兴起助力操作系统新格局
操作系统是计算机系统的核心软件,管理和控制硬件与软件资源,为用户和应用程序提供高效、安全的运行环境。Linux作为开源、跨平台的操作系统,具有高度可定制性、稳定性和安全性,广泛应用于服务器、云计算、物联网等领域。其发展得益于庞大的社区支持,多种发行版如Ubuntu、Debian、Fedora等满足不同需求。
81 5
|
2月前
|
算法 Linux
深入探索Linux内核的内存管理机制
本文旨在为读者提供对Linux操作系统内核中内存管理机制的深入理解。通过探讨Linux内核如何高效地分配、回收和优化内存资源,我们揭示了这一复杂系统背后的原理及其对系统性能的影响。不同于常规的摘要,本文将直接进入主题,不包含背景信息或研究目的等标准部分,而是专注于技术细节和实际操作。
|
2月前
|
存储 缓存 网络协议
Linux操作系统的内核优化与性能调优####
本文深入探讨了Linux操作系统内核的优化策略与性能调优方法,旨在为系统管理员和高级用户提供一套实用的指南。通过分析内核参数调整、文件系统选择、内存管理及网络配置等关键方面,本文揭示了如何有效提升Linux系统的稳定性和运行效率。不同于常规摘要仅概述内容的做法,本摘要直接指出文章的核心价值——提供具体可行的优化措施,助力读者实现系统性能的飞跃。 ####
|
9月前
|
运维 Linux
Linux系统调优详解(二)——CPU负载查看相关命令
Linux系统调优详解(二)——CPU负载查看相关命令
181 10
|
6月前
|
存储 运维 监控
在Linux中,发现CPU负载过大,接下来怎么办?
在Linux中,发现CPU负载过大,接下来怎么办?

热门文章

最新文章