当前位置:   article > 正文

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

centos7 阿里源404

一、配置阿里源


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

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

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

  1. [root@linuxprobe yum.repos.d]# mv Centos-7.repo Centos-Base.repo
  2. [root@linuxprobe yum.repos.d]#
  3. [root@linuxprobe yum.repos.d]# ls
  4. Centos-Base.repo packagekit-media.repo rhel7.repo //其中rhel7.repo为自己配置的本地Yum软件仓库

  第3步:更新镜像源

  1. [root@linuxprobe yum.repos.d]# yum clean all //清楚缓存
  2. Loaded plugins: langpacks, product-id, subscription-manager
  3. This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
  4. Cleaning repos: base extras updates
  5. Cleaning up everything
  6. [root@linuxprobe yum.repos.d]#
  7. [root@linuxprobe yum.repos.d]# yum makecache //生成缓存
  8. Loaded plugins: langpacks, product-id, subscription-manager
  9. This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
  10. http://mirrors.aliyun.com/centos/7Server/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
  11. Trying other mirror.
  12. 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"
  13. Trying other mirror.
  14. 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"
  15. Trying other mirror.
  16. ^C
  17. Current download cancelled, interrupt (ctrl-c) again within two seconds
  18. to exit.

 

二、配置失败


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

  1. http://mirrors.aliyun.com/centos/7Server/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
  2. Trying other mirror.
  3. 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"
  4. Trying other mirror.
  5. 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"
  6. Trying other mirror.
  7. ---------------------------------------省略部分输出内容--------------------------------------------

 

 失败原因: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步:再次更新镜像源

  1. [root@linuxprobe yum.repos.d]# yum clean all
  2. Loaded plugins: langpacks, product-id, subscription-manager
  3. This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
  4. Cleaning repos: base extras rhel7 updates
  5. Cleaning up everything
  6. [root@linuxprobe yum.repos.d]# yum makecache
  7. Loaded plugins: langpacks, product-id, subscription-manager
  8. This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
  9. base | 3.6 kB 00:00:00
  10. extras | 2.9 kB 00:00:00
  11. rhel7 | 4.1 kB 00:00:00
  12. updates | 2.9 kB 00:00:00
  13. (1/14): base/x86_64/group_gz | 165 kB 00:00:02
  14. (2/14): extras/x86_64/filelists_db | 217 kB 00:00:02
  15. (3/14): extras/x86_64/other_db | 106 kB 00:00:00
  16. (4/14): rhel7/group_gz | 134 kB 00:00:00
  17. (5/14): base/x86_64/other_db | 2.6 MB 00:00:02
  18. (6/14): rhel7/filelists_db | 3.0 MB 00:00:00
  19. (7/14): rhel7/primary_db | 3.4 MB 00:00:00
  20. (8/14): rhel7/other_db | 1.3 MB 00:00:00
  21. (9/14): updates/x86_64/filelists_db | 4.5 MB 00:00:00
  22. (10/14): updates/x86_64/other_db | 573 kB 00:00:00
  23. (11/14): updates/x86_64/primary_db | 7.6 MB 00:00:03
  24. base/x86_64/primary_db FAILED ======================== ] 796 kB/s | 23 MB 00:00:17 ETA
  25. http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/04efe80d41ea3d94d36294f7107709d1c8f70db11e152d6ef562da344748581a-primary.sqlite.bz2: [Errno -1] Metadata file does not match checksum
  26. Trying other mirror.
  27. (12/14): base/x86_64/primary_db | 6.0 MB 00:00:00
  28. base/x86_64/filelists_db FAILED
  29. 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"
  30. Trying other mirror.
  31. (13/14): base/x86_64/filelists_db | 7.3 MB 00:00:00
  32. extras/x86_64/primary_db FAILED
  33. 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"
  34. Trying other mirror.
  35. (14/14): extras/x86_64/primary_db | 165 kB 00:00:00
  36. Metadata Cache Created //缓存创建完成
 

四、结果检验


   我们尝试安装Apache服务程序来检测阿里源是否配置成功,如下所示:

  1. [root@linuxprobe yum.repos.d]# yum install -y httpd
  2. Loaded plugins: langpacks, product-id, subscription-manager
  3. This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
  4. Resolving Dependencies
  5. --> Running transaction check
  6. ---> Package httpd.x86_64 0:2.4.6-17.el7 will be updated
  7. ---> Package httpd.x86_64 0:2.4.6-90.el7.centos will be an update
  8. --> Processing Dependency: httpd-tools = 2.4.6-90.el7.centos for package: httpd-2.4.6-90.el7.centos.x86_64
  9. --> Running transaction check
  10. ---> Package httpd-tools.x86_64 0:2.4.6-17.el7 will be updated
  11. ---> Package httpd-tools.x86_64 0:2.4.6-90.el7.centos will be an update
  12. --> Finished Dependency Resolution
  13. Dependencies Resolved
  14. =============================================================================================================================================================
  15. Package Arch Version Repository Size
  16. =============================================================================================================================================================
  17. Updating:
  18. httpd x86_64 2.4.6-90.el7.centos base 2.7 M
  19. Updating for dependencies:
  20. httpd-tools x86_64 2.4.6-90.el7.centos base 91 k
  21. Transaction Summary
  22. =============================================================================================================================================================
  23. Upgrade 1 Package (+1 Dependent package)
  24. Total download size: 2.8 M
  25. Downloading packages:
  26. No Presto metadata available for base
  27. 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
  28. Public key for httpd-tools-2.4.6-90.el7.centos.x86_64.rpm is not installed
  29. (1/2): httpd-tools-2.4.6-90.el7.centos.x86_64.rpm | 91 kB 00:00:02
  30. (2/2): httpd-2.4.6-90.el7.centos.x86_64.rpm | 2.7 MB 00:00:02
  31. -------------------------------------------------------------------------------------------------------------------------------------------------------------
  32. Total 994 kB/s | 2.8 MB 00:00:02
  33. Retrieving key from http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  34. Importing GPG key 0xF4A80EB5:
  35. Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
  36. Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
  37. From : http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  38. Running transaction check
  39. Running transaction test
  40. Transaction test succeeded
  41. Running transaction
  42. Updating : httpd-tools-2.4.6-90.el7.centos.x86_64 1/4
  43. Updating : httpd-2.4.6-90.el7.centos.x86_64 2/4
  44. Cleanup : httpd-2.4.6-17.el7.x86_64 3/4
  45. Cleanup : httpd-tools-2.4.6-17.el7.x86_64 4/4
  46. Verifying : httpd-tools-2.4.6-90.el7.centos.x86_64 1/4
  47. Verifying : httpd-2.4.6-90.el7.centos.x86_64 2/4
  48. Verifying : httpd-tools-2.4.6-17.el7.x86_64 3/4
  49. Verifying : httpd-2.4.6-17.el7.x86_64 4/4
  50. Updated:
  51. httpd.x86_64 0:2.4.6-90.el7.centos
  52. Dependency Updated:
  53. httpd-tools.x86_64 0:2.4.6-90.el7.centos
  54. Complete! //安装成功

 

 最后


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

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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/黑客灵魂/article/detail/823323
推荐阅读
相关标签
  

闽ICP备14008679号