centos6如何添加阿里云centos和epel源

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

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值