国内服务器更换国外源为国内源,达到源提速的目的,适用于大部分场景。
阿里云开源镜像站:https://developer.aliyun.com/mirror/
一、优先备份
在修改前做好良好的习惯,备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
二、下载源和替换
使用下面两种方式的其中一种。
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
#或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
三、更新缓存
#清除缓存
yum clean all
#更新缓存
yum makecache
四、更新源
#更新yum源
yum -y update