CentOS 7 停更后如何配置 YUM 源?(Vault、EPEL、第三方镜像完整指南)

2024 年 6 月 30 日,CentOS 7 已经正式 停止维护(EOL),这意味着官方不再提供安全更新和新软件包。 但是很多企业生产环境仍在运行 CentOS 7,运维人员经常需要通过 YUM 安装或更新软件包。那问题来了:YUM 源失效后怎么办?

别急,这里给大家整理了三种解决方案,帮助你在 CentOS 7 环境下继续正常使用 YUM。

如果有复制格式问题,请从网盘直接下载,文章最后提供了下载地址。


1、使用 Vault 镜像(官方归档源)

CentOS 官方将旧版本的软件包归档到了 Vault,可以通过修改 YUM 配置文件指向 Vault 地址。 在 /etc/yum.repos.d/CentOS-Base.repo 中写入以下内容:

复制代码
[base]
name=CentOS-$releasever - Base
baseurl=http://vault.centos.org/7.9.2009/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centos7
enabled=1

[updates]
name=CentOS-$releasever - Updates
baseurl=http://vault.centos.org/7.9.2009/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centos7
enabled=1

[extras]
name=CentOS-$releasever - Extras
baseurl=http://vault.centos.org/7.9.2009/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centos7
enabled=1

✅ 特点:官方归档,长期可用。

⚠️ 注意:Vault 里的包不会再更新,只能作为历史版本存档。


2、配置 EPEL 源

EPEL (Extra Packages for Enterprise Linux) 是 CentOS 用户经常用到的扩展源,里面有很多官方仓库没有的软件。

安装方法很简单:

复制代码
sudo yum install epel-release

配置完成后,你就可以通过 yum install 安装更多工具和软件包了。


3、使用国内第三方镜像(推荐)

为了提升下载速度,可以直接使用国内高校和云厂商的镜像源。下面推荐两个:

🔹 阿里云镜像

复制代码
[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.aliyun.com/centos/7.9.2009/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centos7
enabled=1

[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.aliyun.com/centos/7.9.2009/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centos7
enabled=1

[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.aliyun.com/centos/7.9.2009/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centos7
enabled=1

🔹 清华大学镜像

复制代码
[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centos7
enabled=1

[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centos7
enabled=1

[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/7.9.2009/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centos7
enabled=1

✅ 特点:国内访问速度快,适合生产环境。

⚠️ 注意:有些第三方镜像会逐步下线,建议同时保留 Vault 备用。

一键切换 CentOS 7 YUM 源的 bash 脚本:

链接: https://pan.quark.cn/s/1f338406405f


总结

  • Vault 源:官方归档,长期可用,但不更新。
  • EPEL 源:扩展软件库,安装额外工具必备。
  • 第三方镜像:速度快,推荐阿里云或清华镜像。

👉 建议:生产环境使用 Vault + 国内镜像 双保险,保证稳定性和下载速度。

相关推荐
开开心心就好8 分钟前
发票合并打印工具,多页布局设置实时预览
linux·运维·服务器·windows·pdf·harmonyos·1024程序员节
火车叼位28 分钟前
脚本伪装:让 Python 与 Node.js 像原生 Shell 命令一样运行
运维·javascript·python
予枫的编程笔记40 分钟前
【Linux进阶篇】从基础到实战:grep高亮、sed流编辑、awk分析,全场景覆盖
linux·sed·grep·awk·shell编程·文本处理三剑客·管道命令
Sheep Shaun41 分钟前
揭开Linux的隐藏约定:你的第一个文件描述符为什么是3?
linux·服务器·ubuntu·文件系统·缓冲区
Tfly__1 小时前
在PX4 gazebo仿真中加入Mid360(最新)
linux·人工智能·自动驾驶·ros·无人机·px4·mid360
陈桴浮海1 小时前
【Linux&Ansible】学习笔记合集二
linux·学习·ansible
迎仔1 小时前
06-存储设备运维进阶:算力中心的存储管家
运维
生活很暖很治愈1 小时前
Linux——环境变量PATH
linux·ubuntu
?re?ta?rd?ed?1 小时前
linux中的调度策略
linux·运维·服务器
深圳市九鼎创展科技1 小时前
瑞芯微 RK3399 开发板 X3399 评测:高性能 ARM 平台的多面手
linux·arm开发·人工智能·单片机·嵌入式硬件·边缘计算