//以下操作需要 root 权限
//进入 repo 目录
cd /etc/yum.repos.d
//建议备份原文件
cp CentOS-Base.repo CentOS-Base.repo.bak
//AppStream 和 Extras 方法同上
vim CentOS-Base.repo
//修改为以下内容
[BaseOS]
name=CentOS-$releasever - Base
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
vim CentOS-AppStream.repo
//修改内容
[AppStream]
name=CentOS-$releasever - AppStream
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
vim CentOS-Extras.repo
//修改内容
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.aliyun.com/centos/$releasever/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
//清除缓存
yum clean all
//建立缓存
yum makecache