刚安装的Centos7怎么更换镜像资源库

时间:2025-6-6    作者:老大夫    分类: Linux


因为CentOS7已经停止维护了,所以镜像资源站要改用国内阿里云的。

步骤:
备份原有仓库配置:

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

下载阿里云镜像配置:
bash
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

清理缓存并重建:

bash
yum clean all
yum makecache

安装SL小火车等镜像 需要启用EPEL仓库,官方镜像没有sl小火车这种安装包

bash
yum install -y epel-release
yum install -y sl

如果安装EPEL仓库失败的话
如果遇到 "Could not resolve host" 错误,先手动下载并安装 EPEL:

bash
rpm -ivh https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm


扫描二维码,在手机上阅读

推荐阅读: