成功解决CentOS7中yum能ping通外网,但是无法下载问题
今天安装完centos7后,使用yum安装vim时出现连接国外源超时情况,想通过yum update来解决问题,但是出现以下情况:
通过ping www.baidu.com,网络是通的。怀疑是CentOS-Base.repo文件出了问题。
通过命令将该文件备份:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
通过命令查看一下本地源情况:
yum repolist all
发现已经全部被禁用掉。通过更换源的命令,仍无法解决
最后想到通过以下网址去下载相应版本的repo文件,然后上传到/etc/yum.repos.d/
网易镜像库
https://mirrors.163.com/.help/centos.html
阿里云镜像库
http://mirrors.aliyun.com/repo/
运行以下命令生成缓存:
yum clean all
yum makecache
再执行yum repolist all
查看
成功设置国内源。执行安装命令依赖命令,成功!