YumRepo Error: All mirror URLs are not using ftp, http[s] or file.

一开始这个遇到这个问题,去百度找了好几个回答,都是说DNS配置不正确,防火墙没关,还有让修改网络适配器为桥接模式,于是盲目的跟着修改,发现压根没用。于是,只能静下心来思考,慢慢找出真正原因。

一、首先确保我的虚拟机网络是通的。

网卡域名服务器配置:
cat /etc/sysconfig/network-scripts/ifcfg-eth0
在这里插入图片描述
然后cat /etc/resolv.conf,这里的nameserver与网卡配置中的DNS配置对应就可。

search localdomain
nameserver 223.5.5.5
nameserver 223.6.6.6

测试网络是否通:ping www.baidu.com
在这里插入图片描述
网络是通的,排除DNS域名,防火墙没关,网络适配器必须修改为桥接这种可能性。

二、网上还有些人说是/etc/yum.repos.d/CentOS-Base.repo这个文件的配置问题,注释掉mirrorlist这个配置项就能成功,试下看看。

在这里插入图片描述
mirrorlist都注释掉了,执行sudo yum update试试
在这里插入图片描述
还是没能成功,但是报错信息不是All mirror URLs are not using ftp, http[s] or file.了,而是404 not find

于是猜想,应该是配置中的链接访问不了,然后把baseurl这个配置的链接去浏览器访问:http://mirror.centos.org/centos/ r e l e a s e v e r / u p d a t e s / releasever/updates/ releasever/updates/basearch/
在这里插入图片描述
果然是404!!!原来是这个外国站点挂了。

三、解决404问题,把源站点配置改为国内清华大学站点https://mirrors.tuna.tsinghua.edu.cn/centos-vault,最终成功。

这里参考了这位老兄的文章,https://blog.csdn.net/fangeqin/article/details/106170479?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-3.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-3.control

确认清华大学站点能访问:
在这里插入图片描述
修改yum源站点配置:vi /etc/yum.repos.d/CentOS-Base.repo
对照清华大学镜像站中的目录修改后如下:

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/os/x86_64/
gpgcheck=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/os/x86_64/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/updates/x86_64/
gpgcheck=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/os/x86_64/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/extras/x86_64/
gpgcheck=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/os/x86_64/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/centosplus/x86_64/
gpgcheck=1
enabled=0
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/os/x86_64/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/contrib/x86_64/
gpgcheck=1
enabled=0
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/os/x86_64/RPM-GPG-KEY-CentOS-6

四、验证 执行yum install vim

在这里插入图片描述
搞定。

  • 83
    点赞
  • 176
    收藏
    觉得还不错? 一键收藏
  • 20
    评论
评论 20
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值