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

至此,完成更改。

目录
相关文章
|
19小时前
|
NoSQL Ubuntu Linux
【操作系统】实验三 编译 Linux 内核
【操作系统】实验三 编译 Linux 内核
3 1
|
23小时前
|
运维 Kubernetes 持续交付
构建高效自动化运维体系:基于容器技术的持续集成与部署实践
【5月更文挑战第13天】 在现代软件开发周期中,持续集成(CI)和持续部署(CD)已成为提升开发效率、保障产品质量的关键环节。随着云计算和微服务架构的普及,容器技术如Docker和Kubernetes为运维领域带来了革命性的变革。本文旨在探讨如何利用容器技术构建一个高效、可靠的自动化运维体系,实现从代码提交到产品发布的全过程自动化管理。通过深入分析容器化技术的核心原理,结合实际案例,我们将阐述如何优化持续集成流程、确保自动化测试的覆盖率、以及实现无缝的持续部署。
|
1天前
|
运维 Kubernetes 测试技术
容器技术:优化软件测试流程的利器
本文介绍了容器技术的概念、优势和历史发展,对比了容器与虚拟机的区别,并提及了Docker和Kubernetes等常见容器技术。容器作为轻量级虚拟化工具,提供高效、灵活的应用部署方式,广泛应用于软件开发、云计算和微服务架构。随着技术演进,容器将在边缘计算、人工智能等领域发挥更大作用,推动行业变革。
11 3
|
2天前
|
运维 Kubernetes Devops
构建高效稳定的云基础设施:DevOps与容器技术的结合
【5月更文挑战第12天】 在当今快速发展的信息技术时代,企业需要灵活、快速地响应市场变化并持续交付高质量的软件产品。本文将探讨如何通过结合DevOps文化和容器技术来构建一个高效且稳定的云基础设施。我们将讨论DevOps的核心概念及其如何加速开发周期,以及容器技术如Docker和Kubernetes如何提供一致性、可移植性和扩展性。最后,文章将介绍实际案例,展示这种结合如何在现代运维实践中实现自动化部署、持续集成和微服务架构管理。
|
2天前
|
Linux Windows 编译器
|
3天前
|
存储 算法 Linux
【Linux】线程的内核级理解&&详谈页表以及虚拟地址到物理地址之间的转化
【Linux】线程的内核级理解&&详谈页表以及虚拟地址到物理地址之间的转化
|
3天前
|
安全 Linux
【Linux】详解用户态和内核态&&内核中信号被处理的时机&&sigaction信号自定义处理方法
【Linux】详解用户态和内核态&&内核中信号被处理的时机&&sigaction信号自定义处理方法
|
3天前
|
存储 Linux
【Linux】对信号产生的内核级理解
【Linux】对信号产生的内核级理解
|
18天前
|
Linux
Linux rsyslog占用内存CPU过高解决办法
该文档描述了`rsyslog`占用内存过高的问题及其解决方案。
41 4
|
1月前
|
移动开发 运维 监控
掌握Linux运维利器:查看CPU和内存占用,轻松解决性能问题!
掌握Linux运维利器:查看CPU和内存占用,轻松解决性能问题!