【问题标题】:centos yum fails installing anything or updating systemcentos yum 无法安装任何东西或更新系统
【发布时间】:2017-02-09 08:23:02
【问题描述】:

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

错误:

[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


【解决方案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 运行 reinstall 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

【讨论】:

  • 当我尝试“--replacepkgs”步骤时,我收到 6 个错误,性质为“安装 centos-release-7-9.2009.1.el7 的文件 /etc/os-release。 centos.x86_64 与 redhat-release-server-7.9-6.el7_9.x86_64 软件包中的文件冲突
  • @michalh 我已经尝试了你的答案,我看到了错误 package centos-release is not installed 。在cat /etc/redhat-release 我有CentOS Linux release 8.5.2111 通过rpm 重新安装centos-release 包我在存储库网站上看不到8.5.2111。而且我无法百胜,尝试安装dnf yum install 抛出错误Error unpacking rpm package yum-4.7.0-4.el8.noarch 你对我有什么建议吗?
【解决方案2】:

我在centos 7中下载一些包时遇到了同样的问题。经过几天的搜索,我找到了解决方案:

  1. 进入 yum repo 目录。

     cd /etc/yum.repos.d.
    
  2. 复制一份 CentOS-Base.repo 文件。

     cp CentOS-Base.repo CentOS-Base.repo.old
    
  3. 编辑 CentOS-Base.repo 文件。注释 mirrorlist 并取消注释 baseurl。

     vi CentOS-Base.repo
    
    [base]
    name=CentOS-$releasever - Base
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
    baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
  1. 现在,当您使用 yum 时,请执行以下操作。

     sudo yum --disablerepo=* --enablerepo=base install httpd
    

yum 更新也是如此。

  sudo yum --disablerepo=* --enablerepo=base install httpd

它现在应该可以工作了。

【讨论】:

    【解决方案3】:

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

    这是为我解决此问题的方法。以 root 身份运行。

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

    "epel" 可以是你喜欢的任何 repo,但这个对我有用。将 [package] 放在命令中,就像写的那样,而不是你要安装的包。

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

    【讨论】:

      【解决方案4】:

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

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

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

      【讨论】:

        【解决方案5】:
        yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
        yum -y install yum-utils
        yum-config-manager --enable remi-php74
        

        然后继续您的安装/更新/等

        【讨论】:

          【解决方案6】:

          始终确保 NAT 在您的 centos7 上处于活动状态。特别是当主机有 VMnet2 时。因为有时 VMNet2 可以激活而不是 NAT,因此您将无法通过 centos7 连接到互联网。这只是出现该错误的一个原因。

          【讨论】:

            猜你喜欢
            • 2012-04-24
            • 1970-01-01
            • 2017-11-29
            • 2019-08-11
            • 1970-01-01
            • 1970-01-01
            • 2013-06-29
            • 1970-01-01
            • 2018-09-20
            相关资源
            最近更新 更多