无法打开文件/packages/repodata/repomd.xml

Gay*_*riB 5 mongodb

我正在使用 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
Run Code Online (Sandbox Code Playgroud)

第 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
Run Code Online (Sandbox Code Playgroud)

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

sudo yum install -y mongodb-org
Run Code Online (Sandbox Code Playgroud)

毕竟,我收到以下错误:

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"
Run Code Online (Sandbox Code Playgroud)

服务器操作系统

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"
Run Code Online (Sandbox Code Playgroud)

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

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

sudo yum clean all
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个错误?

Gay*_*riB -1

您应该检查/etc/yum.repos.d/mongodb-org-4.0.repo 文件中的baseurl。我们还可以更改baseurl中的releaseserver版本。

这是我的 /etc/yum.repos.d/mongodb-org-4.0.repo 文件

[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
Run Code Online (Sandbox Code Playgroud)

这个对我有用。