当前位置: 首页 > web >正文

CentOS7执行yum命令报错 Could not retrieve mirrorlist http://mirrorlist.centos.org

CentOS7执行yum命令报错

  • 更新yum源
    • 备份原有源
    • 创建新的源文件
    • 清理并重建缓存

CentOS 7 系统无法连接到 CentOS 的官方镜像站点。这通常是由于网络问题或 CentOS 7 已停止维护导致的(2024年6月30日后 CentOS 7 已进入 EOL)

报错明细:

已加载插件:fastestmirror
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - “Could not resolve host: mirrorlist.centos.org; 未知的错误”
One of the configured repositories failed (未知),
and yum doesn’t have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work “fix” this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo= …
4. Disable the repository permanently, so yum won’t use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable
or
subscription-manager repos --disable=
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=.skip_if_unavailable=true
Cannot find a valid baseurl for repo: base/7/x86_64

更新yum源

备份原有源

mkdir -p /etc/yum.repos.d/backup
mv /etc/yum.repos.d/CentOS-* /etc/yum.repos.d/backup/

创建新的源文件

cat > /etc/yum.repos.d/CentOS-Base.repo <<'EOF'
[base]
name=CentOS-7 - Base
baseurl=https://vault.centos.org/7.9.2009/os/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
enabled=1[updates]
name=CentOS-7 - Updates
baseurl=https://vault.centos.org/7.9.2009/updates/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
enabled=1[extras]
name=CentOS-7 - Extras
baseurl=https://vault.centos.org/7.9.2009/extras/x86_64/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
enabled=1
EOF

清理并重建缓存

yum clean all
yum makecache
http://www.xdnf.cn/news/172.html

相关文章:

  • 使用Java动态数据生成PDF报告:简化您的报告导出流程
  • 利用大模型实现地理领域文档中英文自动化翻译
  • 计算机网络——网络模型
  • 高频面试题:Android MVP/MVVM/MVI这几种架构在实际生产中,各自的优缺点和适用场景是什么
  • Banana Pi BPI-RV2 RISC-V 路由器开发板发售, 全球首款RISC-V路由器
  • Docker设置环境变量
  • 并发设计模式实战系列(2):领导者/追随者模式
  • 基于Django实现农业生产可视化系统
  • 使用Python设置Excel单元格边框
  • 快手本地生活2024年GMV同增200%,“新线城市+AI”将成增长引擎
  • 【嵌入式八股11】STM32
  • (8)VTK C++开发示例 --- 交互式3D部件
  • 【Reading Notes】(8.3)Favorite Articles from 2025 March
  • “星睿O6” AI PC开发套件评测 - 部署PVE搭建All in One NAS服务器
  • STM32单片机入门学习——第40节: [11-5] 硬件SPI读写W25Q64
  • ASP.NET 中 OAuth 2.0/OpenID Connect 深度集成指南
  • Silverlight发展历程(微软2021年已经停止支持Silverlight 5)
  • 【深度学习】【目标检测】【Ultralytics-YOLO系列】YOLOV3核心文件yolo.py解读
  • Redis(二) - Redis命令详解
  • GPU 在机器学习中的应用优势:从技术特性到云端赋能
  • 银行卡风险画像在社交行业网络安全的应用
  • 如何使用 DeepSeek 帮助自己的工作?
  • 进阶版:RESTful API 在不同编程语言中的实现与实践
  • MCP认证难题破解
  • 搜广推校招面经七十八
  • 爬虫学习——Scrapy
  • LangChain4j-第一篇 |几分钟完成deepseek 在线集成
  • 三大等待和三大切换
  • Leetcode 2158. 每天绘制新区域的数量【Plus题】
  • MySQL:Join连接的原理