Redhat7和CentOS7系统配置阿里源失败问题及解决办法([Errno 14] HTTP Error 404 - Not Found)

一、配置阿里源

第1步:下载阿里源的配置文件

[root@linuxprobe ~]# cd /etc/yum.repos.d/
[root@linuxprobe yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo

第2步:将下载的配置文件重命名

[root@linuxprobe yum.repos.d]# mv Centos-7.repo Centos-Base.repo
[root@linuxprobe yum.repos.d]# 
[root@linuxprobe yum.repos.d]# ls
Centos-Base.repo  packagekit-media.repo  rhel7.repo           //其中rhel7.repo为自己配置的本地Yum软件仓库
  第3步:更新镜像源

复制代码

[root@linuxprobe yum.repos.d]# yum clean all       //清楚缓存
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: base extras updates
Cleaning up everything
[root@linuxprobe yum.repos.d]# 
[root@linuxprobe yum.repos.d]# yum makecache       //生成缓存
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
http://mirrors.aliyun.com/centos/7Server/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found        
Trying other mirror.
http://mirrors.aliyuncs.com/centos/7Server/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
Trying other mirror.
http://mirrors.cloud.aliyuncs.com/centos/7Server/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.cloud.aliyuncs.com:80; Connection refused"
Trying other mirror.
^C
 Current download cancelled, interrupt (ctrl-c) again within two seconds
to exit.

二、配置失败

失败现象:在执行"yum makecache"命令的过程中,不断出现如下的错误提示:

http://mirrors.aliyun.com/centos/7Server/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found        
Trying other mirror.
http://mirrors.aliyuncs.com/centos/7Server/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
Trying other mirror.
http://mirrors.cloud.aliyuncs.com/centos/7Server/os/x86_64/repodata/repomd.xml: [Errno 14] curl#7 - "Failed connect to mirrors.cloud.aliyuncs.com:80; Connection refused"
Trying other mirror.
---------------------------------------省略部分输出内容---------------------

失败原因:Centos-Base.repo配置文件中的$releasever变量解析错误,导致整个URL地址错误。这种情况一般发生在Redhat系统安装Centos源(我的系统是Redhat 7)

在这里插入图片描述

我为什么说是URL地址错误呢?因为我在浏览器中输入地址 “http://mirrors.aliyun.com/centos/”,发现并无 7Server/目录。因此,应该是$releasever变量解析成了"7Server",进而导致了错误的发生。

在这里插入图片描述

经检查发现,正确的URL地址为 http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml,其中的"7"是指系统版本号。

在这里插入图片描述

三、解决办法

这里给出我的解决办法,仅供参考:

第1步:编辑阿里源配置文件
[root@linuxprobe yum.repos.d]# vim Centos-Base.repo
第2步:将全文中所有的 "$releasever" 字符串替换成 "7",因为我的系统是7版本

输入 ":" 进入末行模式
然后输入 %s/$releasever/7/g 
保存并退出

在这里插入图片描述
第3步:再次更新镜像源

[root@linuxprobe yum.repos.d]# yum clean all
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: base extras rhel7 updates
Cleaning up everything
[root@linuxprobe yum.repos.d]# yum makecache 
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
base                                                                                                                                  | 3.6 kB  00:00:00     
extras                                                                                                                                | 2.9 kB  00:00:00     
rhel7                                                                                                                                 | 4.1 kB  00:00:00     
updates                                                                                                                               | 2.9 kB  00:00:00     
(1/14): base/x86_64/group_gz                                                                                                          | 165 kB  00:00:02     
(2/14): extras/x86_64/filelists_db                                                                                                    | 217 kB  00:00:02     
(3/14): extras/x86_64/other_db                                                                                                        | 106 kB  00:00:00     
(4/14): rhel7/group_gz                                                                                                                | 134 kB  00:00:00     
(5/14): base/x86_64/other_db                                                                                                          | 2.6 MB  00:00:02     
(6/14): rhel7/filelists_db                                                                                                            | 3.0 MB  00:00:00     
(7/14): rhel7/primary_db                                                                                                              | 3.4 MB  00:00:00     
(8/14): rhel7/other_db                                                                                                                | 1.3 MB  00:00:00     
(9/14): updates/x86_64/filelists_db                                                                                                   | 4.5 MB  00:00:00     
(10/14): updates/x86_64/other_db                                                                                                      | 573 kB  00:00:00     
(11/14): updates/x86_64/primary_db                                                                                                    | 7.6 MB  00:00:03     
base/x86_64/primary_db         FAILED                                          ========================                    ] 796 kB/s |  23 MB  00:00:17 ETA 
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/04efe80d41ea3d94d36294f7107709d1c8f70db11e152d6ef562da344748581a-primary.sqlite.bz2: [Errno -1] Metadata file does not match checksum
Trying other mirror.
(12/14): base/x86_64/primary_db                                                                                                       | 6.0 MB  00:00:00     
base/x86_64/filelists_db       FAILED                                          
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/41232548001a78473ae0f2d4b92e1ec28f7a0593e0495056515887fe2a39b416-filelists.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
Trying other mirror.
(13/14): base/x86_64/filelists_db                                                                                                     | 7.3 MB  00:00:00     
extras/x86_64/primary_db       FAILED                                          
http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/b6838225b7b16a5eb051c048d2c0783111dc724393b62c685324b08c31d295cb-primary.sqlite.bz2: [Errno 14] curl#7 - "Failed connect to mirrors.aliyuncs.com:80; Connection refused"
Trying other mirror.
(14/14): extras/x86_64/primary_db                                                                                                     | 165 kB  00:00:00     
Metadata Cache Created             //缓存创建完成

最后
  之前我自己的Redhat虚拟机一直使用的本地Yum源,今天想安装一个程序的时候发现没有相应的软件包,于是想到了配置一个阿里的Yum源。然而,在配置的过程中遇到了上述的问题,幸好通过查阅相关的博客找到了解决问题的办法。不过这个方法直接把路径写死了,感觉不太灵活,希望能帮助到各位!!!!

PS:在修改配置文件后,重新执行yum makecache命令的时候还是出现了地址无法访问的报错信息,其实这个并不影响。如果不想看到报错信息的话,把下图中红色框框内的信息删掉就可以了

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值