在centos7中使用yum命令时候报错:|后台服务器|码途山海.智隐长卷 -

程序人生|重庆纽新

找回密码
立即注册

QQ登录

只需一步,快速开始

欢迎访问【程序人生-重庆纽新】,本网站为软件开发人员视觉的IT资讯、软件开发中各种问题的解决办法!!
搜索
发新帖


2308

积分

0

好友

259

主题
楼主
发表于 2024-11-18 11:38:42 | 查看: 350| 回复: 0
  1. Loading mirror speeds from cached hostfile
  2. Could not retrieve mirrorlist [url]http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock[/url] error was
  3. 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"
复制代码
  1. 已加载插件:fastestmirror
  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; 未知的名称或服务"


  4. One of the configured repositories failed (未知),
  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
复制代码



问题原因
出现这个错误是因为使用的 CentOS 7 仓库已经被归档,当前的镜像地址无法找到所需的文件。CentOS 7 的官方支持已经结束,部分仓库已被移至归档库。这导致了你的 yum 命令无法找到所需的元数据文件。CentOS 7 的官方仓库在 2024 年 6 月 30 日之后已经停止维护。因此,使用最新的 CentOS 7 官方仓库可能会遇到问题。
解决方法
进入/etc/yum.repos.d目录下找到 CentOS-Base.repo
进入目录,将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. #baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
  17. baseurl=http://vault.centos.org/7.9.2009/os/$basearch/
  18. gpgcheck=1
  19. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

  20. #released updates
  21. [updates]
  22. name=CentOS-$releasever - Updates
  23. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
  24. #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
  25. #baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
  26. baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/
  27. gpgcheck=1
  28. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

  29. #additional packages that may be useful
  30. [extras]
  31. name=CentOS-$releasever - Extras
  32. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
  33. #$baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
  34. #baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
  35. baseurl=http://vault.centos.org/7.9.2009/extras/$basearch/
  36. gpgcheck=1
  37. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

  38. #additional packages that extend functionality of existing packages
  39. [centosplus]
  40. name=CentOS-$releasever - Plus
  41. #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
  42. #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
  43. #baseurl=http://vault.centos.org/7.9.2009/x86_64/os/
  44. baseurl=http://vault.centos.org/7.9.2009/centosplus/$basearch/
  45. gpgcheck=1
  46. enabled=0
  47. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
复制代码

然后执行:
  1. sudo yum clean all
  2. sudo yum makecache
复制代码
阿里云镜像源
以下两个命令都可以,执行完成后进入/etc/yum.repos.d
  1. curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
复制代码
  1. wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
复制代码
然后查看 :
  1. cat CentOS-Base.repo
复制代码
看看baseURL是否有阿里云镜像。
然后可以执行:
  1. sudo yum clean all
  2. sudo yum makecache
复制代码





收藏回复 只看该作者 道具 举报

高级模式
B Color Image Link Quote Code Smilies



QQ|小黑屋| 码途山海.智隐长卷 渝ICP备15002301号-2   渝公网安备50011202504426

GMT+8, 2025-5-17 23:29 , Processed in 0.041934 second(s), 23 queries .

©Copyright 程序人生!

©2012-2015重庆纽新

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