CentOS 8中 更新或下载时报错:为仓库 ‘appstream‘ 下载元数据失败 : Cannot prepare internal mirrorlist

一、错误重现

CentOS Stream 8 - AppStream                                                                0.0 B/s | 0 B 00:00
Errors during downloading metadata for repository 'appstream':
      - Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8-stream&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]
错误:为仓库 'appstream' 下载元数据失败 : Cannot prepare internal mirrorlist: Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8-stream&arch=x86_64&repo=AppStream&infra=stock [Could not resolve host: mirrorlist.centos.org]

或者

Failed to set locale, defaulting to C.UTF-8
CentOS Linux 8 - AppStream                                                                0.0 B/s | 0 B 00:00
Errors during downloading metadata for repository 'appstream':
     - Curl error (6): Couldn't resolve host name for http://mirrorlist.centos.org/?release=8&arch=x86_64&repo=AppStream&infra=container [Could not resolve host: mirrorlist.centos.org]
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=container [Could not resolve host: mirrorlist.centos.org]

原因 : CentOS Linux 8已于 2021年12月31日停止更新和维护,由于CentOS 团队从官方镜像中移除CentOS 8的所有包,所以在使用yum源安装或更新会报上述失败错误。

进入仓库源文件夹下

cd /etc/yum.repos.d/

修改镜像配置内容

sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

清空原有缓存,并重新生成

yum clean all && yum makecache

更新软件包

yum update -y

在这里插入图片描述


成功解决了!

如果CentOS 7也报相同错误可以使用相同方法。

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-22 11:28:04       52 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-22 11:28:04       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-22 11:28:04       45 阅读
  4. Python语言-面向对象

    2024-07-22 11:28:04       55 阅读

热门阅读

  1. 【MAUI】动态界面

    2024-07-22 11:28:04       21 阅读
  2. 小白C语言基础详解:C 语言的内存管理

    2024-07-22 11:28:04       16 阅读
  3. 等保测评深度探索:揭秘安全合规的幕后英雄

    2024-07-22 11:28:04       18 阅读
  4. Linux命令更新-文本处理grep

    2024-07-22 11:28:04       20 阅读
  5. 事务

    事务

    2024-07-22 11:28:04      20 阅读
  6. 为什么vue3项目中推荐使用const,而不是let语法

    2024-07-22 11:28:04       20 阅读
  7. NLP专业术语及工具【hanlp、jiolp】

    2024-07-22 11:28:04       18 阅读
  8. 【Python】探索 Python 中的 any 和 all 方法

    2024-07-22 11:28:04       19 阅读