首页 > 解决方案 > 无法打开文件 /packages/repodata/repomd.xml

问题描述

我正在使用 Redhat Linux 服务器并尝试在其上安装 MongoDB。

我正在按照链接中给出的步骤操作:https ://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/

第 1 步:创建一个 /etc/yum.repos.d/mongodb-org-4.0.repo 文件,以便您可以使用 yum 直接安装 MongoDB。

sudo nano /etc/yum.repos.d/mongodb-org-4.0.repo

第 2 步:将以下代码复制并粘贴到新创建的文件中。

[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc

第 3 步:要安装特定版本的 MongoDB,请单独指定每个组件包,并将版本号附加到包名称中,如下例所示:

sudo yum install -y mongodb-org

毕竟,我收到以下错误:

Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
file:///packages/repodata/repomd.xml: [Errno 14] curl#37 - "Couldn't open file /packages/repodata/repomd.xml"
Trying other mirror.`


One of the configured repositories failed (local),
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=localrepo ...

 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 localrepo
    or
        subscription-manager repos --disable=localrepo

 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=localrepo.skip_if_unavailable=true

failure: repodata/repomd.xml from localrepo: [Errno 256] No more mirrors to try.
file:///packages/repodata/repomd.xml: [Errno 14] curl#37 - "Couldn't open file /packages/repodata/repomd.xml"

服务器操作系统

NAME="Red Hat Enterprise Linux Server"
VERSION="7.3 (Maipo)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="7.3"
PRETTY_NAME="Red Hat Enterprise Linux"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:7.3:GA:server"
HOME_URL="https://www.redhat.com/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7"
REDHAT_BUGZILLA_PRODUCT_VERSION=7.3
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="7.3"

我已经按照以下步骤操作,但这些在我的情况下不起作用:

sudo rm -rf /etc/yum.repos.d/mongodb-org-4.0.repo

sudo yum clean all

我该如何解决这个错误?

标签: mongodb

解决方案


根据您的错误消息,您似乎遇到了名称服务器问题,这可能涉及各种解决方案,正如redhat.com 的这个答案所描述的那样。我的mongodb-org-4.0.repo文件看起来和你的一样,除了版本 4.4 并且一切正常。好吧,起初我不是这样找到这篇文章的,但我的问题是我不小心在文件末尾插入了一个空格mongodb-org-4.4.repo

我发现这个Unix & Linux Stack Exchange帖子有一些可能的修复,其中之一是更新到最新的 CentOS。这个ServerFault帖子也有一个 Errno 14 错误消息,就像你看到的那样,但这个解决方案是禁用 SELinux。


推荐阅读