因為阿里源文件里面已經(jīng)包含了AppStream甲抖、Base教沾、centosplus、Extras和PowerTools的相關(guān)內(nèi)容朱转,所以需要把這些文件改名為bak蟹地,不讓系統(tǒng)執(zhí)行。
cd /etc/yum.repos.d/
mv /etc/yum.repos.d/CentOS-AppStream.repo /etc/yum.repos.d/CentOS-AppStream.repo.bak
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
mv /etc/yum.repos.d/CentOS-centosplus.repo /etc/yum.repos.d/CentOS-centosplus.repo.bak
mv /etc/yum.repos.d/CentOS-Extras.repo /etc/yum.repos.d/CentOS-Extras.repo.bak
mv /etc/yum.repos.d/CentOS-PowerTools.repo /etc/yum.repos.d/CentOS-PowerTools.repo.bak
如果安裝了wget可以執(zhí)行以下命令:
wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
如果沒有安裝wget藤为,可以用curl來執(zhí)行以下命令:
curl -o CentOS-Base.repo http://阿里鏡像網(wǎng)址/repo/Centos-8.repo
或者也可以先安裝wget怪与。
檢查一下是否安裝成功:
ls -l /etc/yum.repos.d/
執(zhí)行以下命令,確認是否更改成功:
cat /etc/yum.repos.d/CentOS-Base.repo
這樣就完成了將本地CentOS Linux 8的dnf安裝源更換為國內(nèi)源缅疟。
運行以下命令生成一下緩存:
dnf makecache