解决
进入目录,备份
cd /etc/yum.repos.d/
mkdir repo_bak
mv *.repo repo_bak/
换源
wget http://mirrors.aliyun.com/repo/Centos-7.repo
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
除系统 yum 缓存并生成新的 yum 缓存
yum clean all # 清除系统所有的 yum 缓存
yum makecache # 生成 yum 缓存
安装 epel 源
yum list | grep epel-release
yum install -y epel-release
使用阿里开源镜像提供的 epel 源
wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum clean all # 清除系统所有的 yum 缓存
yum makecache # 生成 yum 缓存
其他
CentOS 8
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
或
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo
或
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-6.repo