我今天遇到了这个奇怪的错误,并且无法修复它:
root@server# yum -y update
Loaded plugins: allowdowngrade
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. </html>/
removing mirrorlist with no valid mirrors: /var/cache/yum/addons/mirrorlist.txt
Error: Cannot retrieve repository metadata (repomd.xml) for repository: addons. Please verify its
path and try again
root@server#
禁用 repo“插件”:
root@server# yum update --disablerepo=addons
Loaded plugins: allowdowngrade
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. </html>/
removing mirrorlist with no valid mirrors: /var/cache/yum/base/mirrorlist.txt
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again
root@server#
使用“yum clean all”:
root@server# yum clean all
Loaded plugins: allowdowngrade
Cleaning up Everything
root@server# yum -y update
Loaded plugins: allowdowngrade
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. </html>/
removing mirrorlist with no valid mirrors: /var/cache/yum/addons/mirrorlist.txt
Error: Cannot retrieve repository metadata (repomd.xml) for repository: addons. Please verify its path and try again
root@server#
编辑 22-09-2011:rpm --verify centos-release yum
root@server# rpm --verify centos-release yum
..5....T c /etc/issue
..5....T c /etc/issue.net
S.5....T c /etc/yum.repos.d/CentOS-Base.repo
missing c /etc/yum.repos.d/CentOS-Debuginfo.repo
S.5....T c /etc/yum.repos.d/CentOS-Vault.repo
package yum is not installed
root@server#
我该如何解决这个问题?
答案1
“无法检索存储库元数据”错误看起来像是转移注意力的借口。真正的错误似乎是这样的:
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. </html>/
你的 Yum repo 文件是否损坏了?
/etc/yum.conf
和处的文件由和包/etc/yum.repos.d/*.repo
提供(使用 进行测试)。yum
centos-release
rpm -q --whatprovides /etc/yum.conf /etc/yum.repos.d/*
尝试根据 RPM 文件验证文件/etc/yum.repos.d/
。有任何变化吗?
在以下示例中,文件 CentOS-Base.repo 已被本地修改:
% rpm --verify centos-release yum
S.5....T c /etc/yum.repos.d/CentOS-Base.repo
如果你发现这些文件确实被更改了,那么你可以尝试重新安装 rpm, 或者仅提取您需要的几个文件并手动将它们移到位。请先备份旧文件,以便稍后进行调查。
答案2
尝试yum clean all
并重试您的初始yum -y update
答案3
似乎您的服务器正在拉取空的镜像列表,或者无法连接到镜像列表服务器。首先使用以下命令检查您的服务器是否确实正在拉取镜像列表:
lynx http://mirrorlist.centos.org/?release=5&arch=i386&repo=addons
lynx http://mirrorlist.centos.org/?release=5&arch=i386&repo=os
如果您看到空白页面,则很可能是镜像已关闭或列表为空。您可以禁用镜像,并在 baseurl 中使用直接 centos 镜像。为此,请注释掉镜像列表在 /etc/yum.repos.d/CentOS-Base.repo 中并确保取消注释基本网址如果它已经被评论了。