CentOS7执行 yum install 提示“Could not resolve host: mirrorlist.cento ...

打印 上一主题 下一主题

主题 879|帖子 879|积分 2637

其实这个问题之前就碰到过,时间太久了忘了这里就做个记载
我这边用的是 VMWare+CentOS7(CentOS-7-x86_64-DVD-2207-02.iso)
但是在执行 yum install gcc-c++ 提示:
  1. Loading mirror speeds from cached hostfile
  2. Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
  3. 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
  4. One of the configured repositories failed (Unknown),
  5. and yum doesn't have enough cached data to continue. At this point the only
  6. safe thing yum can do is fail. There are a few ways to work "fix" this:
  7.      1. Contact the upstream for the repository and get them to fix the problem.
  8.      2. Reconfigure the baseurl/etc. for the repository, to point to a working
  9.         upstream. This is most often useful if you are using a newer
  10.         distribution release than is supported by the repository (and the
  11.         packages for the previous distribution release still work).
  12.      3. Run the command with the repository temporarily disabled
  13.             yum --disablerepo=<repoid> ...
  14.      4. Disable the repository permanently, so yum won't use it by default. Yum
  15.         will then just ignore the repository until you permanently enable it
  16.         again or use --enablerepo for temporary usage:
  17.             yum-config-manager --disable <repoid>
  18.         or
  19.             subscription-manager repos --disable=<repoid>
  20.      5. Configure the failing repository to be skipped, if it is unavailable.
  21.         Note that yum will try to contact the repo. when it runs most commands,
  22.         so will have to try and fail each time (and thus. yum will be be much
  23.         slower). If it is a very temporary problem though, this is often a nice
  24.         compromise:
  25.             yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true
  26. Cannot find a valid baseurl for repo: base/7/x86_64
复制代码
就是说 mirrorlist.centos.org 这个所在无法访问,因 CentOS 7 的官方镜像源已不再维护了,所以我们只需要替换掉这个所在就可以了
我们找到这个配置文件
  1. vi /etc/yum.repos.d/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. baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
  15. gpgcheck=1
  16. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  17. [updates]
  18. name=CentOS-$releasever - Updates
  19. baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
  20. gpgcheck=1
  21. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  22. [extras]
  23. name=CentOS-$releasever - Extras
  24. baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
  25. gpgcheck=1
  26. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
  27. [centosplus]
  28. name=CentOS-$releasever - Plus
  29. baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
  30. gpgcheck=1
  31. enabled=0
  32. gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
复制代码
然后我们再去执行 yum install 应该就可以了,如果照旧不行的话就 ping 一下 mirrors.aliyun.com 看是不是网络配置问题

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

老婆出轨

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表