如何解决在Centos 5上安装yum install无效的释放错误

当我尝试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 

如何解决它?

在.repo文件中将?release=5.2更改为?release=5

来自/etc/yum.repos.d/ CentOS-Base.repo文件中mirrorlist属性中的URL被定义为错误。 它已经将版本号硬编码为5.2而不是5 。 我不推荐使用版本号硬编码,而是build议在URL中使用系统提供的variables,如baseurl条目中所示。

所以你想要这样的东西,而不是每个条目(保持现有的repo=价值):

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

在文件“/ etc / yum / vars / releasever”中添加一个完整的版本号(例如'5')。 您可能还需要创build目录“/ etc / yum / vars /”。 这样做可以避免直接编辑任何回购文件的需要,而且您的自定义值通过软件包和操作系统升级持续存在; 只要记住适当地更改值(如果您升级到新的操作系统版本等)。