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
更新镜像源
#清除缓存yum clean all
#生成缓存yum makecache
[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up everything
Cleaning up list of fastest mirrors
[root@localhost ~]# yum makecache
转载请注明:学时网 » CentOS7更换镜像源