1.背景:centos6正常情况下添加这两个源在生成缓存和装包的时候会报错,因为源已经被移走了,报错信息和原因如下:
root@7ea0ba50d2c1 yum.repos.d]# yum makecache fast
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
centos6.9 | 3.7 kB 00:00
centos6.9/group_gz | 226 kB 00:00
centos6.9/filelists_db | 6.4 MB 00:00
centos6.9/other_db | 2.8 MB 00:00
http://mirrors.aliyun.com/epel/6/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
2.那这种情况我们该怎么办呢,首先我们还是按他官方这个正常下载这两个镜像源文件。
[root@7ea0ba50d2c1 yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
[root@7ea0ba50d2c1 yum.repos.d]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
3.其实阿里云的镜像地址挪地方了,我们换下里面的默认地址即可
#替换默认centos6下载地址
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
sed -i 's|http://mirrors.aliyun.com/centos|https://mirrors.aliyun.com/centos-vault/centos|g' /etc/yum.repos.d/CentOS-Base.repo
#替换默认epel下载地址,这个地址在上面的图片centos6 eple源 readmi那个文件里面写明了的
sed -i 's|http://mirrors.aliyun.com/epel|http://archives.fedoraproject.org/pub/archive/epel|gp' /etc/yum.repos.d/epel.repo
4.重新生成缓存成功,YES。。
[root@7ea0ba50d2c1 yum.repos.d]# yum makecache fast
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.7 kB 00:00
epel | 4.7 kB 00:00
extras | 3.4 kB 00:00
updates | 3.4 kB 00:00
Metadata Cache Created
[root@7ea0ba50d2c1 yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, ovl
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
repo id repo name status
base CentOS-6 - Base - mirrors.aliyun.com 6,713
epel Extra Packages for Enterprise Linux 6 - x86_64 12,581
extras CentOS-6 - Extras - mirrors.aliyun.com 47
updates CentOS-6 - Updates - mirrors.aliyun.com 1,193
repolist: 20,534