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

CentOS 7 镜像源失效解决方案(2025年)

执行  yum update  报错:

yum install -y yum-utils \ > device-mapper-persistent-data \ > lvm2 --skip-broken 已加载插件:fastestmirror, langpacks Loading mirror speeds from cached hostfile 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=<repoid> ... 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 <repoid> or subscription-manager repos --disable=<repoid> 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=<repoid>.skip_if_unavailable=true Cannot find a valid baseurl for repo: base/7/x86_64 

2024年6月30日,CentOS 7正式结束生命周期(EOL),官方停止维护支持。原本依赖的默认镜像源(如mirrorlist.centos.org)已无法访问,导致yum安装失败并报错

使用第三方镜像源

(如阿里云、腾讯云)仍维护CentOS 7的镜像仓库

以阿里云镜像为例

        1.备份原来的源:

sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

        2.下载阿里云的源:

sudo curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

        3.更新缓存:

sudo yum clean all
sudo yum makecache

 这样就可以了。如果提示找不到 curl 命令,先安装它:

sudo yum install -y curl
验证镜像源可用性

执行以下命令测试新配置是否生效:

yum repolist                 # 查看已启用的仓库
yum search nginx             # 测试软件包搜索
yum install -y telnet        # 测试安装功能

http://www.dtcms.com/a/109197.html

相关文章:

  • 【Mysql】之索引详解
  • 游戏无法启动?XINPUT1_3.dll 丢失的终极解决方案
  • 国产替代新选择:CCLink IE与EtherCAT网关在制药行业的应用,配置详解
  • python之 “__init__.py” 文件
  • DeepSeek-R1 面试题汇总
  • SAP-ABAP:SAP ABAP UPDATE 语句用法详解
  • 如何像母语一样学习英语
  • VMware ESXi:企业级虚拟化平台详解
  • MySQL-- 函数(单行函数): 日期和时间函数
  • Linux内核TCP/IP协议栈中的设计模式:从面向对象到系统级软件的跨界实践
  • 数据结构——顺序表
  • 思维链(Chain-of-Thought, CoT)与强化学习区别
  • Java基础之反射的基本使用
  • linux命令-find指令
  • 卫星升空织密天网,卫星电话架起天地一体通信桥梁
  • 数据结构与算法——单链表的实现及增、插、删、查、印、毁
  • 【c++深入系列】:类与对象详解(中)
  • Golang定时任务管理(中文日志+防重复执行)
  • React 项目使用 pdf.js 及 Elasticpdf 教程
  • lvgl避坑记录
  • lodash库介绍(一个现代JavaScript实用工具库,提供模块化、性能优化和额外功能)JavaScript库(防抖、节流、函数柯里化)JS库
  • 每日一题洛谷P8664 [蓝桥杯 2018 省 A] 付账问题c++
  • 【C++】nlohmann::json 配置加载技术实践:从基础到高级应用
  • OpenLayers:如何控制Overlay的层级?
  • 如何为Linux/Android Kernel 5.4和5.15添加 fuse passthrough透传功能 ?
  • 如何通过管理系统提升团队协作效率
  • 大模型学习二:DeepSeek R1+蒸馏模型组本地部署与调用
  • css动态设置div宽高,calc函数
  • Unity中的动态合批使用整理
  • Vue中虚拟DOM创建到挂载的过程