如图所示,问题出在yum源上,可以尝试用ping 去连,如果ping不通说明源不可用
解决方案
在CentOS中更改镜像源可以通过编辑/etc/yum.repos.d/CentOS-Base.repo文件实现。以下是更改为阿里云镜像源的步骤:
备份当前的CentOS-Base.repo文件:
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
下载阿里云的CentOS镜像源配置文件:
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
清除缓存并生成新的缓存:
sudo yum clean all
sudo yum makecache
完成上述步骤后,系统的镜像源就会更换为阿里云的镜像源。如果您使用的是其他版本的CentOS,请确保下载对应版本的镜像源配置文件。
如果wget也无法使用,从互联网下载直接替换etc/yum.repos.d/CentOS-Base.repo就可以