1、备份旧repo配置:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下载阿里云源repo配置文件:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
3、依据cenos社区官方发布的说明替换相应的repo文件参数(注销mirrorlist选项,开启baseurl选项):
minorver=8.5.2111
sudo sed -e "s|^mirrorlist=|#mirrorlist=|g" \
-e "s|^#baseurl=http://mirror.centos.org/$contentdir/$releasever/AppStream/$basearch/os/|baseurl=http://mirrors.aliyun.com/centos-vault/$minorver/extras/\$basearch/os/|g" \
-i.bak \
/etc/yum.repos.d/CentOS-Linux-AppStream.repo
minorver=8.5.2111
sudo sed -e "s|^mirrorlist=|#mirrorlist=|g" \
-e "s|^#baseurl=http://mirror.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/|baseurl=http://mirrors.aliyun.com/centos-vault/$minorver/extras/\$basearch/os/|g" \
-i.bak \
/etc/yum.repos.d/CentOS-Linux-BaseOS.repo
(注释:以上2段命令替换的是CentOS-Linux-AppStream.repo和CentOS-Linux-BaseOS.repo文件中的参数,如果dnf makecache时其它repo文件报错,按照这2个命令对比参数自行修改参数或直接修改报错的repo文件即可。)
4、清理、重生成YUM源
dnf clean all
dnf makecache