安装 wget (已安装可忽略)

yum install -y wget

进入目录

cd /etc/yum.repos.d/

创建目录

mkdir backup

默认源配备份

mv C* backup/

下载阿里云yum源

wget -O /etc/yum.repos.d/CenOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

centOS8 有一些改动 替换了CentOS-Base.repo 需要删除原来的CentOS-AppStream.repo 如果不行 直接把当前那个目录文件都删除了吧

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

清除旧缓存

yum clean all

创建新缓存

yum makecache

更新yum

yum update -y

参考阿里云 镜像站
https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b11rMVwPl