1.備份原Base源
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak
# ====== 更換清華源請使用 ======
cp CentOS-Base.repo CentOS-Base.repo.bak
2.更換國內源
下面的操作任選一個即可
阿里鏡像源
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
清華鏡像源
sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn|g' \
-i.bak \
/etc/yum.repos.d/CentOS-*.repo
3.更新軟件包緩存
yum makecache
參考:
阿里源CentOS 鏡像:https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b113id1k6
清華源CentOS 鏡像使用幫助:https://mirrors.tuna.tsinghua.edu.cn/help/centos/