centos yum无法安装任何东西或更新系统

问题描述 投票:0回答:3

我试图在CentOS上安装一个软件包,但是当我运行“yum”命令时它会抛出错误。互联网连接正常。我尽力保持清洁,但问题仍然存在。

错误:

[root@dcos-master3 ~]# yum install ntp

Loaded plugins: fastestmirror


     One of the configured repositories failed (Unknown),
     and yum doesn't have enough cached data to continue. At this point the only
     safe thing yum can do is fail. There are a few ways to work "fix" this:

         1. Contact the upstream for the repository and get them to fix the problem.

         2. Reconfigure the baseurl/etc. for the repository, to point to a working
            upstream. This is most often useful if you are using a newer
            distribution release than is supported by the repository (and the
            packages for the previous distribution release still work).

         3. Run the command with the repository temporarily disabled
                yum --disablerepo=<repoid> ...

         4. Disable the repository permanently, so yum won't use it by default. Yum
            will then just ignore the repository until you permanently enable it
            again or use --enablerepo for temporary usage:

                yum-config-manager --disable <repoid>
            or
                subscription-manager repos --disable=<repoid>

         5. Configure the failing repository to be skipped, if it is unavailable.
            Note that yum will try to contact the repo. when it runs most commands,
            so will have to try and fail each time (and thus. yum will be be much
            slower). If it is a very temporary problem though, this is often a nice
            compromise:

                yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

    Cannot find a valid baseurl for repo: base/$releasever/x86_64

我的yum repolist是下一个:

[root@dcos-master3 ~]# yum repolist list
Loaded plugins: fastestmirror
https://yum.dockerproject.org/repo/main/centos/%24releasever/repodata/repomd.xml: [Errno 14] HTTPS Error 403 - Forbidden
Trying other mirror.
To address this issue please refer to the below knowledge base article

https://access.redhat.com/solutions/69319

If above article doesn't help to resolve this issue please create a bug on https://bugs.centos.org/

repolist: 0

如果我列出了repolist:

[root@dcos-master3 ~]# yum repolist
Loaded plugins: fastestmirror
https://yum.dockerproject.org/repo/main/centos/%24releasever/repodata/repomd.xml: [Errno 14] HTTPS Error 403 - Forbidden
Trying other mirror.
To address this issue please refer to the below knowledge base article

https://access.redhat.com/solutions/69319

If above article doesn't help to resolve this issue please create a bug on https://bugs.centos.org/

repo id                             repo name                             status
base/$releasever/x86_64             CentOS-$releasever - Base             0
dockerrepo/$releasever              Docker Repository                     0
extras/$releasever/x86_64           CentOS-$releasever - Extras           0
updates/$releasever/x86_64          CentOS-$releasever - Updates          0
repolist: 0
centos yum
3个回答
1
投票

在尝试任何此类操作之前,请备份您的机器,您可能会更多/完全损坏您的操作系统

似乎你的yum变量$ releasever在某种程度上是腐败的,它通常是由于某些不明原因而在机器上缺少centos-release软件包引起的。

您可以通过以下方式检查您是否有包裹:

    rpm -qi centos-release

你可能会看到:

    "package centos-release is not installed"

首先找出以root身份执行的确切的centos版本:

    cat /etc/redhat-release

你会看到这样的事情:

    CentOS Linux release 7.3.1611 (Core)

您可以通过以下方式从repo获取centos-release软件包:

    wget http://vault.centos.org/centos/7.3.1611/updates/x86_64/Packages/centos-release-7-3.1611.el7.centos.2.5.x86_64.rpm

现在通过rpm运行重新安装centos-release软件包:

    sudo rpm -Uvh --replacepkgs centos-release-7-3.1611.el7.centos.2.5.x86_64.rpm

接下来你可以尝试用yum安装一些东西,你可能会得到:

    [root@dcos-master3 ikerlan]# sudo yum install wget
    error: db5 error(-30969) from dbenv->open: BDB0091 DB_VERSION_MISMATCH: Database environment version mismatch
    error: cannot open Packages index using db5 - (-30969)
    error: cannot open Packages database in /var/lib/rpm
    CRITICAL:yum.main:

    Error: rpmdb open failed

现在您可以尝试重新启动计算机或尝试使用以下命令重建rpm db:

    rpm --rebuilddb

0
投票

我试图在CentOS 7上安装MariaDB时遇到了这个问题。我非常沮丧,经过多次搜索后找到了这个link的答案。

这是解决这个问题的原因。以root身份运行。

# yum --disablerepo "*" --enablerepo epel install [package]
# yum clean all

“epel”可以是你喜欢的任何回购,但这个对我有用。将[package]放在命令中,就像写入的那样,而不是您要安装的软件包。

运行上面的操作后,退出root并运行您在遇到错误之前尝试的任何安装。


0
投票

我注意到在失败的网址中,你的$releasever%24releasever,但它应该是77.14.xx。请检查/etc/yum/var上的yum配置文件,或搜索每个.repo文件,看看它的价值是多少。它可能已损坏。

有关如何设置这些变量的更多信息,请参阅Red Hat文档。

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/sec-using_yum_variables

© www.soinside.com 2019 - 2024. All rights reserved.