> 文章列表 > YumRepo Error: All mirror URLs are not using ftp, http[s] or file解决办法

YumRepo Error: All mirror URLs are not using ftp, http[s] or file解决办法

YumRepo Error: All mirror URLs are not using ftp, http[s] or file解决办法

文章目录

    • 一、问题背景
    • 二、问题原因
    • 三、解决方法

一、问题背景

CentOS6.5利用yum -y install gcc命令安装程序报错YumRepo Error: All mirror URLs are not using ftp, http[s] or file.Eg. Invalid release/repo/arch combination/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/6/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base
、以及利用yum makecache命令时报错Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again。
YumRepo Error: All mirror URLs are not using ftp, http[s] or file解决办法

二、问题原因

对应的镜像库中无法找到对应的repomd.xml文件

原因分析:CentoS 6 停止维护更新日期2020年11月30日,其中
CentOS 7 停止维护更新日期2024年6月30日
CentOS 8 停止维护更新日期2021年12月31日,其他具体信息可参阅官网https://wiki.centos.org/zh/About/Product
YumRepo Error: All mirror URLs are not using ftp, http[s] or file解决办法

三、解决方法

原centos/6/ 下已经没有相关的文件,尝试修改本地镜像配置文件

步骤:

cd /etc/yum.repos.d

修改之前先保存一个备份文件

cp CentOS-Base.repo CentOS-Base.repo.bak
vi  CentOS-Base.repo

因为$releasever 获取的是centos的版本号,我的centos获取的版本为6,但是镜像站中无对应版本文件,因此需要修改本地配置文件

:%s/$releasever/7/g #将文件中$releasever全部改成7或其他版本

修改后文件内容如下图:

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#[base]
name=CentOS-7 - Base
mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/7/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#released updates 
[updates]
name=CentOS-7 - Updates
mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#additional packages that may be useful
[extras]
name=CentOS-7 - Extras
mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7 - Plus
mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6#contrib - packages by Centos Users
[contrib]
name=CentOS-7 - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/7/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

保存退出:

:wq

清除和重新生成缓存

yum clean all 
rm -rf /var/cache/yum
yum makecache 

完成之后再次通过yum -y install XXX 尝试安装软件