备份所有 CentOS 源
cd /etc/yum.repos.d/
ls -lha
rename '.repo' '.repo.bak' CentOS*.repo
下载CentOS源
- 如果
curl 不存在或者不好用,手动下载源后上传到 /etc/yum.repos.d/ 目录
# CentOS 7
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel-7.repo https://mirrors.aliyun.com/repo/epel-7.repo
# CentOS 8
curl -o /etc/yum.repos.d/Centos-vault-8.5.2111.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
curl -o /etc/yum.repos.d/epel-archive-8.repo https://mirrors.aliyun.com/repo/epel-archive-8.repo
清理缓存并重新创建缓存
yum clean all
yum makecache