一、简介

  1. One of the configured repositories failed (Unknown),
  2. and yum doesn't have enough cached data to continue. At this point the only
  3. safe thing yum can do is fail. There are a few ways to work "fix" this:
  4. 1. Contact the upstream for the repository and get them to fix the problem.
  5. 2. Reconfigure the baseurl/etc. for the repository, to point to a working
  6. upstream. This is most often useful if you are using a newer
  7. distribution release than is supported by the repository (and the
  8. packages for the previous distribution release still work).
  9. 3. Disable the repository, so yum won't use it by default. Yum will then
  10. just ignore the repository until you permanently enable it again or use
  11. --enablerepo for temporary usage:
  12. yum-config-manager --disable <repoid>
  13. 4. Configure the failing repository to be skipped, if it is unavailable.
  14. Note that yum will try to contact the repo. when it runs most commands,
  15. so will have to try and fail each time (and thus. yum will be be much
  16. slower). If it is a very temporary problem though, this is often a nice
  17. compromise:
  18. yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
  19. Cannot find a valid baseurl for repo: base/7/x86_64

二、解决方案

去修改它大致需要两步

Step1

添加下面一行就可以了

  1. vi /etc/resolv.conf
  2. # 在文件中添加如下内容
  3. nameserver 114.114.114.114

(这是国内的dns服务器系统,还是比较好用的。谷歌的可以使用8.8.8.8)
修改完后service network restart进行重启,试一下yum update命令,应该就可以了。如果还不可以,可以再进行下一步。

Step2

进入 /etc/yum.repos.d ,编辑vi CentOS-Base.repo,修改下面黄色标识的部分(只需要注释掉第十四行,取消注释第十五行就可以了)

  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. [base]
  13. name=CentOS-$releasever - Base
  14. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
  15. baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
  16. gpgcheck=1
  17. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  18. #released updates
  19. [updates]
  20. name=CentOS-$releasever - Updates
  21. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
  22. baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
  23. gpgcheck=1
  24. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  25. #additional packages that may be useful
  26. [extras]
  27. name=CentOS-$releasever - Extras
  28. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
  29. baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
  30. gpgcheck=1
  31. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  32. #additional packages that extend functionality of existing packages
  33. [centosplus]
  34. name=CentOS-$releasever - Plus
  35. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
  36. baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
  37. gpgcheck=1
  38. enabled=0
  39. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  40. CentOS-Base.repo 44L, 1664C

完成上面两步,再重新执行yum update等其它安装命令就可以正常运行了。
本文转载自 :https://blog.csdn.net/zhousenshan/article/details/53140979