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

至此,完成更改。

目录
相关文章
|
1月前
|
运维 Linux Apache
LAMP架构调优(一)——隐藏Apache版本信息
LAMP架构调优(一)——隐藏Apache版本信息
16 1
|
1月前
|
Kubernetes 开发者 Docker
基于容器技术的微服务架构
基于容器技术的微服务架构
33 0
|
17天前
|
Linux Shell 虚拟化
linux 部署docker容器虚拟化平台(二)--------docker 镜像制作方法
linux 部署docker容器虚拟化平台(二)--------docker 镜像制作方法
28 0
|
17天前
|
存储 Linux Shell
centos 部署docker容器 安装 、基本使用方法(一)
centos 部署docker容器 安装 、基本使用方法(一)
32 0
|
29天前
|
关系型数据库 MySQL Nacos
【深入浅出Nacos原理及调优】「实战开发专题」采用Docker容器进行部署和搭建Nacos服务以及“坑点”
【深入浅出Nacos原理及调优】「实战开发专题」采用Docker容器进行部署和搭建Nacos服务以及“坑点”
48 1
|
30天前
|
NoSQL 关系型数据库 MySQL
安装Docker&镜像容器操作&使用Docker安装部署MySQL,Redis,RabbitMQ,Nacos,Seata,Minio
安装Docker&镜像容器操作&使用Docker安装部署MySQL,Redis,RabbitMQ,Nacos,Seata,Minio
392 1
|
1月前
|
运维 监控 Devops
构建高效自动化运维体系:基于容器技术的持续集成与持续部署实践
在数字化转型的浪潮中,企业的IT基础设施和软件交付模式正经历着深刻的变革。传统的运维方式已难以满足快速迭代、灵活扩展的现代业务需求。本文将探讨如何通过容器技术实现高效的自动化运维体系,重点分析持续集成(CI)与持续部署(CD)的实践方法及其对企业运维效率的影响。通过引入微服务架构、容器编排、DevOps文化等概念,我们旨在为读者提供一套全面的自动化运维解决方案,以支持业务的敏捷性和可扩展性。
|
1月前
|
Kubernetes 监控 Linux
容器服务ACK常见问题之新增一台CentOS 5.4内核的节点失败如何解决
容器服务ACK(阿里云容器服务 Kubernetes 版)是阿里云提供的一种托管式Kubernetes服务,帮助用户轻松使用Kubernetes进行应用部署、管理和扩展。本汇总收集了容器服务ACK使用中的常见问题及答案,包括集群管理、应用部署、服务访问、网络配置、存储使用、安全保障等方面,旨在帮助用户快速解决使用过程中遇到的难题,提升容器管理和运维效率。
|
1月前
|
Shell Docker 容器
Docker的常用命令:加速你的容器化开发与部署
Docker的常用命令:加速你的容器化开发与部署
56 0
|
1月前
|
Kubernetes 测试技术 持续交付
探索微服务架构下的持续集成与部署最佳实践
本文将深入探讨在微服务架构下实施持续集成与部署的最佳实践,介绍如何利用现代化工具和流程来实现自动化测试、持续集成、灰度发布等关键环节,帮助开发团队提升交付效率和质量。