1)先安裝wget
執行命令 yum install -y wget
[root@localhost ~]# yum install -y wget
2) 查詢國內鏡像源
打開阿里鏡像http://mirrors.aliyun.com/
點擊幫助:
3)下載CentOS 7的repo文件
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
4)更新鏡像源
#清除緩存
yum clean all
#生成緩存
yum makecache
執行命令:yum -y update
更新yum源,等待更新完畢即可。