您所在的位置:首页 / 知识分享

解决CentOS6停止更新支持后yum源失效

2020.12.17

1574

最近CentOS 6已经停止更新支持,同时官方也把yum源删除了,目前CentOS 6系统使用yum命令安装软件包基本都是失败,因此需要更换yum源。

最近CentOS 6已经停止更新支持,同时官方也把yum源删除了,目前CentOS 6系统使用yum命令安装软件包基本都是失败,因此需要更换yum源。

在ssh界面执行以下命令即可一键更换yum源为CentOS的Vault源(包括CentOS官方和阿里云的源):

wget -O /etc/yum.repos.d/CentOS-Base.repo http://file.kangle.odata.cc/repo/Centos-6.repo
wget -O /etc/yum.repos.d/epel.repo http://file.kangle.odata.cc/repo/epel-6.repo
yum makecache


问题描述

Yum 源失效,无法正常使用 Yum,错误信息如下:

复制代码
http://mirrors.aliyun.com/centos/6/updates/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found" 尝试其他镜像。 http://mirrors.aliyuncs.com/centos/6/updates/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 7 - "couldn't connect to host" 尝试其他镜像。 http://mirrors.cloud.aliyuncs.com/centos/6/updates/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'mirrors.cloud.aliyuncs.com'" 尝试其他镜像。 

问题分析

浏览器输入阿里的 Yum 源地址: mirrors.cloud.aliyuncs.com/centos/6

发现已经没有 updates 文件夹了,也找不到 repomd.xml 文件,所以 Yum 运行时报以上错误。

再查看 readme 文件,如下:

复制代码
This directory (and version of CentOS) is deprecated. Please see this FAQ concerning the CentOS release scheme: https://wiki.centos.org/FAQ/General Please keep in mind that 6.0, 6.1, 6.2, 6.3, 6.4 , 6.5, 6.6, 6.7, 6.8 , 6.9 and 6.10 no longer get any updates, nor any security fix's. The whole CentOS 6 is *dead* and *shouldn't* be used anywhere at *all*

看明白了吧,The whole CentOS 6 is dead and shouldn't be used anywhere at all ,阿里已不再维护 CentOS 6 的 Yum 源镜像啦。

同样的,浏览器输入清华的 Yum 源地址:mirrors.tuna.tsinghua.edu.cn/centos/6,里面只有一个 readme 文件,内容和上面一样,说明清华已不再维护 CentOS 6 的 Yum 源镜像啦。

还有就是 163 也一样的结果,都只有一个 readme 文件啦。

问题解决

网站好不容易找到一个 Yum 源还能用,地址:https://vault.centos.org/6.9/
操作简单,把CentOS-Base.repo 里面的东西全部删掉,添加如下内容即可。