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  //緩存創建完成

四、結果檢驗


   我們嘗試安裝Apache服務程序來檢測阿里源是否配置成功,如下所示:

[root@linuxprobe yum.repos.d]# yum install -y httpd Loaded plugins: langpacks, product-id, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.4.6-17.el7 will be updated ---> Package httpd.x86_64 0:2.4.6-90.el7.centos will be an update --> Processing Dependency: httpd-tools = 2.4.6-90.el7.centos for package: httpd-2.4.6-90.el7.centos.x86_64 --> Running transaction check ---> Package httpd-tools.x86_64 0:2.4.6-17.el7 will be updated ---> Package httpd-tools.x86_64 0:2.4.6-90.el7.centos will be an update --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================= Package Arch Version Repository Size ============================================================================================================================================================= Updating: httpd x86_64 2.4.6-90.el7.centos                             base                           2.7 M Updating for dependencies: httpd-tools                           x86_64                           2.4.6-90.el7.centos                             base                            91 k Transaction Summary ============================================================================================================================================================= Upgrade 1 Package (+1 Dependent package) Total download size: 2.8 M Downloading packages: No Presto metadata available for base warning: /var/cache/yum/x86_64/7Server/base/packages/httpd-tools-2.4.6-90.el7.centos.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY- ETA Public key for httpd-tools-2.4.6-90.el7.centos.x86_64.rpm is not installed (1/2): httpd-tools-2.4.6-90.el7.centos.x86_64.rpm                                                                                     |  91 kB  00:00:02 (2/2): httpd-2.4.6-90.el7.centos.x86_64.rpm                                                                                           | 2.7 MB  00:00:02     
------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 994 kB/s | 2.8 MB  00:00:02 Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5: Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>" Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5 From : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : httpd-tools-2.4.6-90.el7.centos.x86_64                                                                                                    1/4 Updating : httpd-2.4.6-90.el7.centos.x86_64                                                                                                          2/4 Cleanup : httpd-2.4.6-17.el7.x86_64                                                                                                                 3/4 Cleanup : httpd-tools-2.4.6-17.el7.x86_64                                                                                                           4/4 Verifying : httpd-tools-2.4.6-90.el7.centos.x86_64                                                                                                    1/4 Verifying : httpd-2.4.6-90.el7.centos.x86_64                                                                                                          2/4 Verifying : httpd-tools-2.4.6-17.el7.x86_64                                                                                                           3/4 Verifying : httpd-2.4.6-17.el7.x86_64                                                                                                                 4/4 Updated: httpd.x86_64 0:2.4.6-90.el7.centos Dependency Updated: httpd-tools.x86_64 0:2.4.6-90.el7.centos Complete! //安裝成功

 最后


   之前我自己的Redhat虛擬機一直使用的本地Yum源,今天想安裝一個程序的時候發現沒有相應的軟件包,於是想到了配置一個阿里的Yum源。然而,在配置的過程中遇到了上述的問題,幸好通過查閱相關的博客找到了解決問題的辦法。不過這個方法直接把路徑寫死了,感覺不太靈活,希望能幫助到各位!!!!

  PS:在修改配置文件后,重新執行yum makecache命令的時候還是出現了地址無法訪問的報錯信息,其實這個並不影響。如果不想看到報錯信息的話,把下圖中紅色框框內的信息刪掉就可以了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM