解决 CentOS 7 官方 yum 仓库无法使用的最佳实践

摘自:https://www.cnblogs.com/zengzuo613/p/18292809

停止维护 CentOS7

2024 年 7 月 1 日 官方停止维护 CentOS 7。该系统内置的 yum.repo 所使用的域名 mirrorlist.centos.org 已不再提供 A 记录。

无法在线安装 vim 等软件

临时方案一 - 更新 CentOS 仓库配置

(1)配置操作

启用 *.repo 中的 baseurl,注释 mirrorlist,将 baseurl 仓库地址替换为 vault.centos.org 存档站点。具体操作如下:

sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo

清除 YUM 缓存,如有需要可再生成新的缓存

yum clean all ; yum makecache

(2)验证方法

在线安装 vim

临时方案二 - 基础仓库替换为阿里云仓库

将 CentOS 7 基础仓库修改为阿里云仓库,具体操作如下:

(1)首先,备份 CentOS 7 基础仓库配置文件

cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

(2)然后,下载阿里云仓库配置文件,并替换系统内置基础仓库(CentOS-Base.repo)配置文件

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/CentOS-7.repo

(3)清除 YUM 缓存,如有需要可再生成新的缓存

yum clean all ; yum makecache

(4)验证方法

在线安装 vim

推荐解决方法

详见顶部原文链接


原文出处:/show_1GW5Oc1fEEa.html