错误:无法找到适用于repo: base的有效基本URL

4
我需要帮忙,请问我在尝试在CentOS 5.9中安装“yum update”,但是出现了错误。
> Loaded plugins: fastestmirror, kmod Loading mirror speeds from cached
> hostfile YumRepo Error: All mirror URLs are not using ftp, http[s] or
> file.  Eg. Invalid release/ removing mirrorlist with no valid mirrors:
> /var/cache/yum/base/mirrorlist.txt Error: Cannot find a valid baseurl
> for repo: base

请帮我修复这个问题。
更新CentOS-Base.repo的内容。
   [base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
exclude=redhat-logos php53*

#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
exclude=redhat-logos php53*

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
exclude=redhat-logos php53*

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
exclude=redhat-logos php53*

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=5$releasever&arch=$basearch&repo=contrib
baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
exclude=redhat-logos php53*

提前感谢您。
2个回答

12
这是因为Centos 5已经过时,需要手动更新Base repo文件以将所有内容指向Centos vault。
源链接:http://realtechtalk.com/Centos_59_Working_Vault_Repo_file-1921-articles 请备份 /etc/yum.repos.d/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-5.9 - Base
#mirrorlist=http://mirrorlist.centos.org/?release=5.9&arch=$basearch&repo=os
baseurl=http://vault.centos.org/5.9/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#released updates
[updates]
name=CentOS-5.9 - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=5.9&arch=$basearch&repo=updates
baseurl=http://vault.centos.org/5.9/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#additional packages that may be useful
[extras]
name=CentOS-5.9 - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=5.9&arch=$basearch&repo=extras
baseurl=http://vault.centos.org/5.9/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-5.9 - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=5.9&arch=$basearch&repo=centosplus
baseurl=http://vault.centos.org/5.9/os/$basearch/centosplus/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#contrib - packages by Centos Users
[contrib]
name=CentOS-5.9 - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=5.9&arch=$basearch&repo=contrib
baseurl=http://vault.centos.org/5.9/os/$basearch/contrib/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

非常感谢您的帮助性回答! - SOUser
同样适用于CentOS 4.8,你只需要将$releasever替换为4.8,mirror.centos.org/centos替换为vault.centos.org即可。 - TmsKtel

2

这可能有两种可能性导致。

1. 软件源版本过旧

根据您的CentOS版本,我尝试通过链接找到操作系统,并从readme文件中获取以下信息。

此目录(和CentOS版本)已过时。对于普通用户,      您应该在路径中使用/5/而不是/5.9/。请参阅此FAQ      有关CentOS发布计划的信息:

https://wiki.centos.org/FAQ/General

如果您知道自己在做什么,并且绝对想保持5.9级别,请转到http://vault.centos.org/获取软件包。请记住,5.9不再获得任何更新

在此链接中,它建议您通过另一个链接查找旧版本。因此,您需要修改CentOS-Base.repo

将所有http://mirror.centos.org/centos/***替换为http://vault.centos.org/***

例如:

Original: baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
New:      baseurl=http://vault.centos.org/$releasever/os/$basearch/

2. 网络问题

检查 镜像服务器 是否可访问。

$ ping mirrorlist.centos.org

如果您遇到以下错误信息。
ping: unknown host mirrorlist.centos.org

为了解决这个问题,可以在 resolv.conf 中添加一个有效的名称服务器(如果您不是root用户,请使用sudo)。
$ echo nameserver 8.8.8.8 > /etc/resolv.conf

我尝试进行ping操作,以下是结果:来自108-43-236-85.rev.customer-net.de (85.236.43.108)的64字节数据:icmp_seq=2 ttl=53 time=364 ms。 - jemz
你能提供一下你的/etc/yum.repos.d/CentOS-Base.repo文件内容吗?这个仓库可能太旧了,所以你在镜像列表服务器上找不到它们。 - Kir Chou
这是结果 http://vault.centos.org/centos/5/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP 错误 404: 找不到页面 尝试其他镜像。 错误:无法检索仓库元数据 (repomd.xml),请验证其路径并重试。 - jemz
我不想获取更新,我只想下载一些我的应用程序运行所需的软件包,但它不允许我这样做。 - jemz
@ jemz,不要使用那个链接,请尝试http://vault.centos.org/5.9/os/x86_64/repodata/repomd.xml,您当前的repo baseurl不能提供正确的信息,您必须先修复它们。 - Kir Chou

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接