1、mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/
2、添加dns
vim/etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 114.114.114.114
#配置完先检查下通不通
3、vi /etc/yum/pluginconf.d/subscription-manager.conf
# 将 “enabled=1” 改为 “enabled=0”
4、mv /etc/yum.repos.d/*.repo mv /etc/yum.repos.d/*.repo.bak
5、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
6、sed -i 's/$releasever/7/g' /etc/yum.repos.d/CentOS-Base.repo
#使用vim,里面的$releasever换成对应的版本
:%s/$releasever/7/g
7、yum clean all
8、yum makecache