备份旧的配置文件:mv CentOS-Base.repo CentOS-Base.repo.bak
下载阿里源的文件: wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
清理缓存
yum clean all
重新生成缓存
yum makecache
最后会报错:[Errno 14] Could not open/read file:///media/cdrom/repodata/repomd.xml
将/etc/yum.repos.d/CentOS-Media.repo里面的enabled=1改成enabled=0即可
转载自:http://blog.csdn.net/kevinwang2016/article/details/72418728
http://blog.163.com/rz_xiaojia/blog/static/11920919820163251413771/