CentOS5.5使用yum时报错Error: Cannot find a valid baseurl for repo: addons

前端之家收集整理的这篇文章主要介绍了CentOS5.5使用yum时报错Error: Cannot find a valid baseurl for repo: addons前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

今天需要用CentOS5.5测试个东西,但是发现在运行yum命令的时候出现下面的错误

  1. Loaded plugins: allowdowngrade,downloadonly,fastestmirror
  2. Determining fastest mirrors
  3. Error: Cannot find a valid baseurl for repo: addons
  4. YumRepo Error: All mirror URLs are not using ftp,http[s] or file.
  5. Eg. Invalid release/
  6. removing mirrorlist with no valid mirrors: /var/cache/yum/addons/mirrorlist.txt
  7. The command '/bin/sh -c rpm --rebuilddb && yum install -y sudo tar openssh-server supervisor keepalived' returned a non-zero code: 1

出现这个问题的原因CentOS5版本太老,官方不再维护了,所以yum默认配置文件中的url不能再使用。

因此,需要把/etc/yum.repos.d/CentOS-Base.repo文件中的url修改

下面是修改前的配置

  1. # CentOS-Base.repo
  2. #
  3. # The mirror system uses the connecting IP address of the client and the
  4. # update status of each mirror to pick mirrors that are updated to and
  5. # geographically close to the client. You should use this for CentOS updates
  6. # unless you are manually picking other mirrors.
  7. #
  8. # If the mirrorlist= does not work for you,as a fall back you can try the
  9. # remarked out baseurl= line instead.
  10. #
  11. #
  12.  
  13. [base]
  14. name=CentOS-$releasever - Base
  15. mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
  16. #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
  17. gpgcheck=1
  18. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  19.  
  20. #released updates
  21. [updates]
  22. name=CentOS-$releasever - Updates
  23. mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
  24. #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
  25. gpgcheck=1
  26. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  27.  
  28. #packages used/produced in the build but not released
  29. [addons]
  30. name=CentOS-$releasever - Addons
  31. mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
  32. #baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
  33. gpgcheck=1
  34. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  35.  
  36. #additional packages that may be useful
  37. [extras]
  38. name=CentOS-$releasever - Extras
  39. mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
  40. #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
  41. gpgcheck=1
  42. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  43.  
  44. #additional packages that extend functionality of existing packages
  45. [centosplus]
  46. name=CentOS-$releasever - Plus
  47. mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
  48. #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
  49. gpgcheck=1
  50. enabled=0
  51. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  52.  
  53. #contrib - packages by Centos Users
  54. [contrib]
  55. name=CentOS-$releasever - Contrib
  56. mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
  57. #baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
  58. gpgcheck=1
  59. enabled=0
  60. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

下面是修改后的配置

  1. # CentOS-Base.repo
  2. #
  3. # The mirror system uses the connecting IP address of the client and the
  4. # update status of each mirror to pick mirrors that are updated to and
  5. # geographically close to the client. You should use this for CentOS updates
  6. # unless you are manually picking other mirrors.
  7. #
  8. # If the mirrorlist= does not work for you,as a fall back you can try the
  9. # remarked out baseurl= line instead.
  10. #
  11. #
  12.  
  13. [base]
  14. name=CentOS-5.9 - Base
  15. #mirrorlist=http://mirrorlist.centos.org/?release=5.9&arch=$basearch&repo=os
  16. baseurl=http://vault.centos.org/5.9/os/$basearch/
  17. gpgcheck=1
  18. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  19.  
  20. #released updates
  21. [updates]
  22. name=CentOS-5.9 - Updates
  23. #mirrorlist=http://mirrorlist.centos.org/?release=5.9&arch=$basearch&repo=updates
  24. baseurl=http://vault.centos.org/5.9/updates/$basearch/
  25. gpgcheck=1
  26. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  27.  
  28. #packages used/produced in the build but not released
  29. [addons]
  30. name=CentOS-5.9 - Addons
  31. #mirrorlist=http://mirrorlist.centos.org/?release=5.9&arch=$basearch&repo=addons
  32. baseurl=http://vault.centos.org/5.9/addons/$basearch/
  33. gpgcheck=1
  34. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  35.  
  36. #additional packages that may be useful
  37. [extras]
  38. name=CentOS-5.9 - Extras
  39. #mirrorlist=http://mirrorlist.centos.org/?release=5.9&arch=$basearch&repo=extras
  40. baseurl=http://vault.centos.org/5.9/extras/$basearch/
  41. gpgcheck=1
  42. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  43.  
  44. #additional packages that extend functionality of existing packages
  45. [centosplus]
  46. name=CentOS-5.9 - Plus
  47. #mirrorlist=http://mirrorlist.centos.org/?release=5.9&arch=$basearch&repo=centosplus
  48. baseurl=http://vault.centos.org/5.9/centosplus/$basearch/
  49. gpgcheck=1
  50. enabled=0
  51. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
  52.  
  53. #contrib - packages by Centos Users
  54. [contrib]
  55. name=CentOS-5.9 - Contrib
  56. #mirrorlist=http://mirrorlist.centos.org/?release=5.9&arch=$basearch&repo=contrib
  57. baseurl=http://vault.centos.org/5.9/contrib/$basearch/
  58. gpgcheck=1
  59. enabled=0
  60. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

修改后,重新使用yum来安装包,一切可以正常工作了。

猜你在找的CentOS相关文章