制作IPA镜像失败

在官方文档中,安装Ironic插件时,出现IPA镜像无法完成制作的情况

拉取镜像会进行报错,一下是报错信息

2026-03-16 09:00:59.060 | CentOS Linux 8 - AppStream 0.0 B/s | 0 B 00:02
2026-03-16 09:00:59.060 | Errors during downloading metadata for repository ‘appstream’:
2026-03-16 09:00:59.060 | - Curl error (6): Couldn’t resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=genclo [Could not resolve host: mirrorlist.centos.org]
2026-03-16 09:00:59.060 | Error: Failed to download metadata for repo ‘appstream’: Cannot prepare internal mirrorlist: Curl error (6): Couldn’t resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=genclo [Could not resolve host: mirrorlist.centos.org]
2026-03-16 09:00:59.399 | Unmount /tmp/dib_build.9mVj2YOm/mnt/tmp/yum
2026-03-16 09:00:59.417 | Unmount /tmp/dib_build.9mVj2YOm/mnt/tmp/in_target.d
2026-03-16 09:00:59.434 | Unmount /tmp/dib_build.9mVj2YOm/mnt/sys
2026-03-16 09:00:59.452 | Unmount /tmp/dib_build.9mVj2YOm/mnt/proc
2026-03-16 09:00:59.471 | Unmount /tmp/dib_build.9mVj2YOm/mnt/dev/pts
2026-03-16 09:00:59.498 | Unmount /tmp/dib_build.9mVj2YOm/mnt/dev
2026-03-16 09:01:00.201 | INFO diskimage_builder.block_device.blockdevice [-] State already cleaned - no way to do anything here
Command ‘[‘disk-image-create’, ‘-o’, ‘/mnt/ironic-agent-ssh’, ‘ironic-python-agent-ramdisk’, ‘centos’, ‘selinux-permissive’, ‘devuser’]’ returned non-zero exit status 1.

答案内容由AI生成,仅供参考:

:white_check_mark: 结论

您遇到的 IPA 镜像构建失败是由于 CentOS 8 官方镜像源失效引起的典型问题。最直接有效的解决方法是更换为华为云等可用的 centos-vault,或更理想的方案是 迁移到仍在维护的操作系统作为构建基础

:pushpin: 建议:openEuler 社区也提供了镜像构建工具(如 eulermaker)和替代方案,可在未来考虑基于 openEuler 构建 Ironic Agent 镜像,提升可持续性与安全性。

点击此处查看详细分析解答

IPA镜像制作失败问题分析与解决方案

根据您提供的错误信息,IPA(Ironic Python Agent)镜像在制作过程中失败,主要原因是 CentOS 8 的软件仓库 mirrorlist.centos.org 无法解析,导致依赖包下载失败。


:magnifying_glass_tilted_left: 错误详情分析

Curl error (6): Couldn’t resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream
Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist

关键问题:

  • mirrorlist.centos.org 域名无法解析(DNS 问题或该域名已停用)。
  • 此问题发生在构建镜像过程中使用 disk-image-create 工具拉取 CentOS 8 AppStream 仓库时。
  • 这是典型的 CentOS Linux 8 生命周期结束(EOL)后镜像源失效所引发的问题。

:warning: 背景说明:CentOS Linux 8 已于 2021 年底停止维护,官方镜像源逐步关闭,很多镜像站不再提供服务或重定向至存档地址(Vault),导致构建流程中断。


:white_check_mark: 解决方案

方案一:更换为可用的 CentOS 镜像源(推荐临时修复)

使用仍可访问的镜像源替代默认的 mirrorlist.centos.org。例如使用 华为云镜像站

# 推荐替换为华为云的 CentOS Vault 源(适用于旧版本)
http://mirrors.huaweicloud.com/centos-vault/

修改方式:

在构建镜像的上下文环境中,手动覆盖 yum 的 repo 配置文件,例如创建或修改 /etc/yum.repos.d/CentOS-AppStream.repo

[appstream]
name=CentOS-$releasever - AppStream
baseurl=http://mirrors.huaweicloud.com/centos-vault/8.5.2111/AppStream/x86_64/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial

您也可以添加 --no-tls-checks 参数(如果因 SSL 问题失败)并指定内部 repo 路径。

:white_check_mark: 提示:您可在构建环境中注入自定义 .repo 文件,避免使用已失效的公共镜像列表。


方案二:迁移到仍在维护的操作系统基础镜像

由于 CentOS 8 已停止更新,长期解决方案是 改用受支持的基础系统,如:

替代系统 优点
CentOS Stream 8 滚动更新,官方延续版本,支持到 2024 年
Rocky Linux 8 社区驱动,RHEL 兼容,长期支持
AlmaLinux 8 稳定替代品,持续维护

构建命令示例(以 Rocky Linux 为例):

disk-image-create -o /mnt/ironic-agent-ssh ironic-python-agent-ramdisk rocky-linux selinux-permissive devuser

需确保 diskimage-builder 支持对应发行版的 element(可通过 elements/ 目录确认是否有 rocky-linuxalmalinux)。


方案三:使用本地缓存或离线镜像

如果您在内网环境或希望避免网络依赖,可:

  1. 提前下载 CentOS 8 Vault ISO 或镜像树;
  2. 搭建本地 HTTP 服务器提供 AppStreamBaseOS 资源;
  3. 在构建时指定 baseurl=http://your-local-mirror/centos/8.5/AppStream/x86_64/os/

:books: 相关参考信息(来自知识库)

  • https://mirrors.huaweicloud.com/centos-vault/ 是华为云提供的 CentOS 存档镜像源,可用于恢复旧版本依赖(由用户 yanzhicong 推荐)。
  • 用户 netfish 曾指出类似问题的根源在于镜像源不可达,并建议“更换为国内镜像源”以解决元数据下载失败问题。
  • CentOS Mirrorlist 因 DNS 无法解析而导致 yum 安装失败,已在多个场景中被确认(如 x2openEuler-upgrade 包安装失败)。

:hammer_and_wrench: 建议操作步骤总结

步骤 操作
1 确认当前使用的 base OS 为 CentOS 8,且构建流程依赖 mirrorlist.centos.org
2 替换 AppStreamBaseOS 源为可用镜像(如华为云 Vault 源)
3 若仍失败,考虑切换至 Rocky Linux / AlmaLinux / CentOS Stream
4 验证构建环境的网络连通性和 DNS 设置
5 若为生产环境,建议升级构建链以摆脱对 EOL 系统的依赖

:white_check_mark: 结论

您遇到的 IPA 镜像构建失败是由于 CentOS 8 官方镜像源失效引起的典型问题。最直接有效的解决方法是更换为华为云等可用的 centos-vault,或更理想的方案是 迁移到仍在维护的操作系统作为构建基础

:pushpin: 建议:openEuler 社区也提供了镜像构建工具(如 eulermaker)和替代方案,可在未来考虑基于 openEuler 构建 Ironic Agent 镜像,提升可持续性与安全性。