在不支持的CentOS 6上,发生了YumRepo错误:所有镜像URL都没有使用ftp,http[s]或file(已解决)

首先

仅提供一种选项:

就在前几天(2020-11-30),CentOS 6的支持已经结束了。

CentOS6_EOL.png

因此,yum install或yum update将输出以下类似的错误消息并失败。

正在加载插件:fastestmirror、ovl
正在设置安装进程
错误:无法检索仓库元数据(repomd.xml):base。请验证其路径并重试。
YumRepo 错误:所有镜像URL未使用ftp、http[s]或文件协议。
例如,无效的版本/仓库/架构组合。
正在移除没有有效镜像的镜像列表:/var/cache/yum/x86_64/6/base/mirrorlist.txt

折中的解决方案

我在 Reddit 上找到以下文章并尝试了一下,问题解决了,所以应该没问题了。

CentOS repositories down?
byu/joetron2030 insysadmin

是的,这就是所提到的 EOL(产品终止支持)。要修复这个问题,你可以更新你的.repo 文件,像这样:

把这行注释掉:mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os

替换为这行:baseurl=http://vault.centos.org/centos/$releasever/os/$basearch/

mirrorlist=http://mirrorlist.centos.org/?をコメントアウトして
かわりに、baseurl=http://vault.centos.org/centos/$releasever/os/$basearch/を追加する

baseurl=http://vault.centos.org/centos/$releasever/os/$basearch/中的”/os/”部分有多种变化,因此可以使用sed命令进行替换,这样更方便。

$ sed -i -e "s/^mirrorlist=http:\/\/mirrorlist.centos.org/#mirrorlist=http:\/\/mirrorlist.centos.org/g" /etc/yum.repos.d/CentOS-Base.repo
$ sed -i -e "s/^#baseurl=http:\/\/mirror.centos.org/baseurl=http:\/\/vault.centos.org/g" /etc/yum.repos.d/CentOS-Base.repo

CentOS-Base.repo经过修改后的内容如下所示。

# 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-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=http://vault.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/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://vault.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/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://vault.centos.org/centos/$releasever/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-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=http://vault.centos.org/centos/$releasever/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-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
baseurl=http://vault.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

最后

就在不久前,一切都没有问题,所以我怀疑是不是支持已经结束,所以我进行了调查,感觉应验了。软件的寿命真是短暂啊。

好了好了。

相关链接

    CentOS 5.x の yum update で Error: Cannot find a valid baseurl for repo: base エラー – Qiita
广告
将在 10 秒后关闭
bannerAds