Couldn‘t resolve host name for http://mirrorlist.centos.org
【问题】
在CentOS8执行sudo yum update -y 软件包更新的时候报错
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]
【原因】
CentOS 8及之前的版本已经进入EOF(End Of Life),因此在CentOS Mirror中不再维护CentOS 的旧版本。它们可从 CentOS Vault 中获取,以供历史参考。
如果我们访问Download - The CentOS Project 可以看到如下的信息
【解决方法】
将镜像更改为vault.centos.org。
1.进入目录
cd /etc/yum.repos.d/
2.执行命令
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
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-*
【参考】
Could not resolve host: mirrorlist.centos.org
无法为 repo 'AppStream' [CentOS] 下载元数据 - 滔天蟹 - 博客园
Fixing Yum Update on Centos 8 Stream Error: Failed to download metadata for repo ‘AppStream’: Cannot prepare internal mirrorlist: No URLs in mirrorlist | Bots!