今天是2020年12月18日,Centos官方已于2020年12月2日停止了对Centos6.x的所有更新,并且下架了包括官方所有的centos6源,目前阿里、163、清华等centos6源已无法使用。
使用yum命令会出现报错

yum install
yum makecache
yum update

等命令均无法使用,会提示url 404 not found。

CentoS 6 停止维护更新日期:2020年11月30日
CentOS 7 停止维护更新日期:2024年6月
CentOS 8 停止维护更新日期:2029年5月
2020年12月2日,centos官方停止了对centos6的所有更新,并且下架了包括官方所有的centos6源,目前阿里、163、清华等centos6源已无法使用。

公司部分服务仍在使用Centos6.5,想通过官方渠道升级至7.0结果遇到问题。yum update遇到404报错,下载了阿里,163等源也是一样,yum makecache时候遇到

Repository base is listed more than once in the configuration
查找发现,目前只能通过vault.centos.org作为源来更新了。需要手动多处源地址才能正常使用。
[root@bbs ~]# cd /etc/yum.repos.d
#进入源文件目录
[root@bbs yum.repos.d]# vim CentOS-Base.repo
#如果下载的是163的源,请编辑CentOS6-Base-163.repo
#如果下载的是阿里云的源,请编辑Centos-6.repo

#这里注意,为什么不用变量$releasever?因为Centos6.5的$releasever值为6,导致下载地址不正确。所以在这里,我们直接写死版本号。
[base]
name=CentOS-6.10 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-6.10 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-6.10 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6.10 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-6.10 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.10/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6

或者可以使用官方的vault仓库作为源

[base]
name=CentOS-6.10 - Base - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.10/os/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-6.10 - Updates - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.10/updates/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-6.10 - Extras - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.10/extras/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6.10 - Plus - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.10/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-6.10 - Contrib - vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.10/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6

其他下载地址同理。

完成上述所有地址修改以后。运行

yum clean all
yum makecache

[root@bbs yum.repos.d]# yum clean all
Loaded plugins: fastestmirror, security
Cleaning repos: base epel extras updates upgrade
Cleaning up Everything
Cleaning up list of fastest mirrors
[root@bbs yum.repos.d]# yum makecache
Loaded plugins: fastestmirror, security
Determining fastest mirrors
base                                                                                                                                                 | 3.7 kB     00:00     
base/group_gz                                                                                                                                        | 220 kB     00:00     
base/filelists_db                                                                                                                                    | 5.9 MB     00:05     
base/primary_db                                                                                                                                      | 4.4 MB     00:02     
base/other_db                                                                                                                                        | 2.8 MB     00:01     
epel                                                                                                                                                 | 3.7 kB     00:00     
epel/group_gz                                                                                                                                        | 220 kB     00:00     
epel/filelists_db                                                                                                                                    | 5.9 MB     00:03     
epel/primary_db                                                                                                                                      | 4.4 MB     00:02     
epel/other_db                                                                                                                                        | 2.8 MB     00:01     
extras                                                                                                                                               | 2.9 kB     00:00     
extras/filelists_db                                                                                                                                  |  11 kB     00:00     
extras/primary_db                                                                                                                                    |  19 kB     00:00     
extras/other_db                                                                                                                                      | 6.6 kB     00:00     
updates                                                                                                                                              | 2.9 kB     00:00     
updates/filelists_db                                                                                                                                 | 4.1 MB     00:02     
updates/primary_db                                                                                                                                   | 5.9 MB     00:03     
updates/other_db                                                                                                                                     | 838 kB     00:00     
upgrade                                                                                                                                              | 2.9 kB     00:00     
upgrade/filelists_db                                                                                                                                 | 4.1 MB     00:02     
upgrade/primary_db                                                                                                                                   | 5.9 MB     00:03     
upgrade/other_db                                                                                                                                     | 838 kB     00:01     
Metadata Cache Created
[root@bbs yum.repos.d]# 

至此Centos6.5已经可以正常使用yum命令了。
建议有条件的,还是尽快升级到Centos7或者Centos8

本文于2020年2月20日更新源地址信息,引用了网友一键飘香的教程

最后修改:2021 年 02 月 20 日
如果觉得我的文章对你有用,请随意赞赏