cd /etc/yum.repos.d/ mv CentOS-Base.repo CentOS-Base.repo.bak # ====== 更换清华源请使用 ====== cp CentOS-Base.repo CentOS-Base.repo.bak
下面的操作任选一个即可
阿里镜像源
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
yum makecache
参考:
阿里源CentOS 镜像:https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b113id1k6
清华源CentOS 镜像使用帮助:https://mirrors.tuna.tsinghua.edu.cn/help/centos/