如何修复 Centos 5 上的 yum install not valid release 错误

如何修复 Centos 5 上的 yum install not valid release 错误

当我尝试 yum 安装任何东西时,我得到:

-bash-3.2# yum install strace
Loading "fastestmirror" plugin
Determining fastest mirrors
 * dag: apt.sw.be
 * lxlabsupdate: download.lxlabs.com
 * rpmforge: fr2.rpmfind.net
 * lxlabslxupdate: download.lxlabs.com
YumRepo Warning: not using ftp, http[s], or file for repos, skipping - 5.2 is not a valid release or hasnt been released yet
removing mirrorlist with no valid mirrors: //var/cache/yum/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base

在 /etc/yum.repos.d 中我有文件:

CentOS-Base.repo         CentOS-Media.repo  mirrors-rpmforge
CentOS-Base.repo.rpmnew  lxlabs.repo        rpmforge.repo

CentOS-Base.repo:

# CentOS-Base.repo
#
# This file uses a new mirrorlist system developed by Lance Davis for CentOS.
# 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=5.2&arch=$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=5.2&arch=$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
#additional packages that may be useful

[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=5.2&arch=$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&rep$
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5

[dag]
name=Dag RPM Repository for Centos
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag

[addons]
name=CentOS-$releasever - Addons
mirrorlist=http://mirrorlist.centos.org/?release=5.2&arch=$basearch&repo=addons
#baseurl=http://mirror.centos.org/centos/$releasever/addons/$basearch/
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-5
enabled=1

如何修复?

答案1

在您的 .repo 文件中更改?release=5.2为。?release=5

答案2

mirrorlist您的 CentOS-Base.repo 文件中属性中的 URL/etc/yum.repos.d/定义错误。它将发布版本号硬编码为5.2代替5。我建议不要对版本号进行硬编码,而是在 URL 中使用系统提供的变量,如 baseurl 条目中所示。

因此,您希望每个条目都使用类似这样的内容(保留现有repo=值):

镜像列表=http://mirrorlist.centos.org/?release=5.2&arch=$basearch&repo=os

答案3

将完整的发行版本号(例如“5”)添加到文件“/etc/yum/vars/releasever”。您可能还需要创建目录“/etc/yum/vars/”。这样做可以避免直接编辑任何 repo 文件,并且您的自定义值在软件包和操作系统升级后仍然有效;只需记住适当更改该值(如果您升级到新的操作系统版本等)。

相关内容