Centos 6.6 上的 yum 错误

yum error on Centos 6.6

失败后 "yum update",yum 无法工作。

如果我尝试启动 "yum update",我得到的结果是:

# yum update
Loaded plugins: dellsysid, fastestmirror
Setting up Update Process
Loading mirror speeds from cached hostfile
YumRepo Error: All mirror URLs are not using ftp, http[s] or file.
Eg. $releasever is not a valid release or hasnt been released yet/
removing mirrorlist with no valid mirrors: /var/cache/yum/x86_64/$releasever/base/mirrorlist.txt
Error: Cannot find a valid baseurl for repo: base

我下载并尝试安装 "centos-release" 但出现错误:

# rpm -Uvh centos-release-6-6.el6.centos.12.2.x86_64.rpm
error: centos-release-6-6.el6.centos.12.2.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: BAD
error: centos-release-6-6.el6.centos.12.2.x86_64.rpm cannot be installed

最奇怪的是:

# rpm -q rpm
package rpm is not installed

如何解决问题并运行 成功 yum?

这个 link 对我有用,检查一下:

https://techjourney.net/centos-yum-rpm-error-rpmts_hdrfromfdno-rpmdbnextiterator-header-v3-rsasha1-signature-key-id-bad/

我对 cents 6.6 也有同样的问题。因为 yum 变量 $releasever 没有正确展开。发出您可能会看到的以下命令:

$ python -c 'import yum, pprint; yb = yum.YumBase();pprint.pprint(yb.conf.yumvar, width=1)'

Loaded plugins: fastestmirror
{'arch': 'i686',
'basearch': 'i386',
'infra': 'stock',
'releasever': '$releasever',
'uuid': '19f9697d-6f4f-428a-848a-f317d7a880fb'}

在这种情况下,releaser 的值应该是 6 而不是 $releasever。所以只需将变量设置为正确的值,一切都会好起来的,使用以下命令:

echo 6 > /etc/yum/vars/releasever

现在您可以检查它是否有效:

$ python -c 'import yum, pprint; yb = yum.YumBase();pprint.pprint(yb.conf.yumvar, width=1)'

Loaded plugins: fastestmirror
{'arch': 'i686',
'basearch': 'i386',
'infra': 'stock',
'releasever': '6',
'uuid': '19f9697d-6f4f-428a-848a-f317d7a880fb'}

现在 yum 命令应该可以正常工作了:)