2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/
CentOS 5wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6 (如果不可用,请拉到最底部使用新方法)wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
直接编辑 /etc/yum.repos.d/Centos-Base.repo ,清空所有内容,替换如下代码:vi /etc/yum.repos.d/Centos-Base.repo[base]name=CentOS-6failovermethod=prioritybaseurl=https://vault.centos.org/6.9/os/x86_64/gpgcheck=0
CentOS 7wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
CentOS 8
进入yum.repos.d目录
cd /etc/yum.repos.d
备份3个源文件cp CentOS-Base.repo CentOS-Base.repo.bakcp CentOS-AppStream.repo CentOS-AppStream.repo.bakcp CentOS-Extras.repo CentOS-Extras.repo.bak
修改3个文件中的地址:sed -i 's/mirrorlist=/#mirrorlist=/g' CentOS-Base.repo CentOS-AppStream.repo CentOS-Extras.reposed -i 's/#baseurl=/baseurl=/g' CentOS-Base.repo CentOS-AppStream.repo CentOS-Extras.reposed -i 's/http:\/\/mirror.centos.org/https:\/\/mirrors.aliyun.com/g' CentOS-Base.repo CentOS-AppStream.repo CentOS-Extras.repo
3、之后运行yum clean all 清空缓存,运行yum makecache生成缓存
