最近在安装docker时碰到centos的归档问题,错误信息如下,以下列出了可行的解决方案:
错误信息
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7\&arch=x86_64\&repo=os\&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"
原因
出现这个错误是因为使用的 CentOS 7 仓库已经被归档,当前的镜像地址无法找到所需的文件。CentOS 7 的官方支持已经结束,部分仓库已被移至归档库。这导致了你的 yum 命令无法找到所需的元数据文件。CentOS 7 的官方仓库在 2024 年 6 月 30 日之后已经停止维护。因此,使用最新的 CentOS 7 官方仓库可能会遇到问题。
解决方案
使用阿里云镜像
重定向网络
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
![](https://i-blog.csdnimg.cn/img_convert/c01726ae91e6190703d5758fcfd9ccc4.png)
下载新的respo
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
![](https://i-blog.csdnimg.cn/img_convert/5aea7aa88d1b211f8efde3f9eca05148.png)
查看CentOS-Base.repo文件
cat /etc/yum.repos.d/CentOS-Base.repo
![](https://i-blog.csdnimg.cn/img_convert/b3cdda45f3b4db6bb81592fcdecce682.png)
清理缓存
yum clear all
yum makecache
![](https://i-blog.csdnimg.cn/img_convert/f9b69f0e30474ae6f5ee7b2923a1fb7a.png)