[root@hcss-ecs-20f8 etc]# sudo yum makecache 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=stock [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=stock [Could not resolve host: mirrorlist.centos.org]
发下由于 CentOS 8 的官方源已经失效。具体步骤如下:
1. 替换为阿里云镜像源
由于 CentOS 8 的官方源已经失效,您可以将系统的 yum 源替换为阿里云的镜像源。以下是具体步骤:
- 备份原有的 repo 文件:
sudo cp /etc/yum.repos.d/CentOS-AppStream.repo /etc/yum.repos.d/CentOS-AppStream.repo.backupsudo cp /etc/yum.repos.d/CentOS-BaseOS.repo /etc/yum.repos.d/CentOS-BaseOS.repo.backupsudo cp /etc/yum.repos.d/CentOS-Extras.repo /etc/yum.repos.d/CentOS-Extras.repo.backup
- 下载阿里云的 repo 文件:
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
3:清理并重建 yum 缓存:
sudo yum clean allsudo yum makecache
2. 使用 vault.centos.org 替换 mirrorlist
如果上述方法仍然无法解决问题,您可以尝试将 mirrorlist
替换为 baseurl
,并指向 vault.centos.org
,这是 CentOS 提供的历史版本软件仓库。
- 编辑 repo 文件:
sudo sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*sudo sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
2:清理并重建 yum 缓存
sudo yum clean allsudo yum makecache