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

时间:2017-02-09 08:23:02

标签: centos yum

我正在尝试在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

如果我列出了重组者:

[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

6 个答案:

答案 0 :(得分: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

答案 1 :(得分:1)

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

  1. 转到 yum 存储库目录。

     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

它现在应该可以工作了。

答案 2 :(得分:0)

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

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

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

&#34; EPEL&#34;可以是你喜欢的任何回购,但这个对我有用。将[package]放在命令中,而不是您要安装的软件包。

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

答案 3 :(得分:0)

我注意到在失败的URL中,您的$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

答案 4 :(得分:0)

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
yum -y install yum-utils
yum-config-manager --enable remi-php74

然后继续安装/更新/ etc

答案 5 :(得分:0)

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