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

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

相关文章:

  • 【刷题Day19】HTTP的各个版本(浅)
  • iOS Google登录
  • 2025妈妈杯数学建模B题完整分析论文
  • 【全部更新】2025妈妈杯D题1-4问mathercupD题数学建模挑战赛D题数学建模思路代码文章教学短途运输货量预测及车辆调度问题
  • 2025MathorcupD题 短途运输货量预测及车辆调度问题 保姆级教程讲解|模型讲解
  • 36V转2.8V3A同步降压恒压WT6043A
  • 下载HBuilder X,使用uniapp编写微信小程序
  • 数控机床中滚珠导轨的作用是什么?
  • 深度学习神经网络全连接笔记day1
  • 深入浅出目标检测:从入门到YOLOv3,揭开计算机视觉的“火眼金睛”
  • 如何评价2025 mathorcup妈妈杯数学建模竞赛?完整建模过程+完整代码论文全解全析来了
  • Spring Boot自动配置原理深度解析:从条件注解到spring.factories
  • 代码随想录算法训练营第二十一天
  • 工作总结(十二)——迁移svn单项目到gitlab上,保留历史提交记录
  • 使用 Docker 安装 Elastic Stack 并重置本地密码
  • STM32CubeMX-H7-15-SPI通信协议读写W25Q64
  • 第11篇:Linux程序访问控制FPGA端HEX<四>
  • C++23 新特性:行拼接前去除空白符 (P2223R2)
  • 相比其他缓存/内存数据库(如 Memcached, Ehcache 等),Redis 在微服务环境中的优势和劣势是什么?
  • 浪涌保护器:纳秒盾支持2/4/8线制,全面防护信号、电源及网络设备 智能防雷设备
  • 牛市早报|今年第二批810亿元超长期特别国债资金下达,支持消费品以旧换新
  • 80后共青团云南省委副书记许思思已任迪庆州委副书记
  • 东风着陆场近日气象条件满足神舟十九号安全返回要求
  • 举牌超200轮!中铁建7.76亿元竞得北京通州梨园宅地
  • 丁俊晖连续7年止步世锦赛16强,中国军团到了接棒的时候
  • “不意外”和“不遗余力”,直击上海商超对接外贸企业