CentOS 7 - yum 不会安装 mongodb

CentOS 7 - yum 不会安装 mongodb

我正在尝试安装 mongodb v3.4MongoDB
首先,我创建“/etc/yum.repo.d/mongodb.repo”,然后将此存储库信息粘贴到文件中:

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

我尝试安装 mongodb-org,但从 yum 收到以下错误:

Loaded plugins: fastestmirror
base

| 3.6 kB  00:00:00     
extras
| 3.4 kB  00:00:00     
https://repo.mongodb.org/yum/redhat/7/mongodb-org/3.4/x86_64/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/



 One of the configured repositories failed (MongoDB Repository),
 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=mongodb-org-3.4 ...

 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 mongodb-org-3.4
    or
        subscription-manager repos --disable=mongodb-org-3.4

 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=mongodb-org-3.4.skip_if_unavailable=true

failure: repodata/repomd.xml from mongodb-org-3.4: [Errno 256] No more mirrors to try.
https://repo.mongodb.org/yum/redhat/7/mongodb-org/3.4/x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 403 - Forbidden

这个错误是因为 SELinux 限制吗?我应该如何允许 yum 安装 mongodb?

答案1

这可能为时已晚,但在遇到同样的问题后,我遵循了以下组合在 AWS Linux 上通过 yum 安装 MongoDB 失败:HTTPS 错误 404 - 未找到(在 Stack Overflow 上)的回应之一在 CentOS 上安装 MongoDB 时出现 Yum 错误?(不是选定的),所以我的步骤是:

sudo rm -rf /etc/yum.repos.d/mongod*
sudo yum clean all

再次创建repo文件

sudo vi /etc/yum.repos.d/mongodb-org-3.4.repo

粘贴以下内容(注意,对于我的系统,我将 '$releasever' 替换为 7):

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

然后我运行了这个,并且成功了:

sudo yum install -y mongodb-org

答案2

我认为您尝试添加exclude目录以/etc/yum.conf防止将来更新,例如:

exclude=mongodb-org,mongodb-org-server,mongodb-org-shell,mongodb-org-mongos,mongodb-org-tools

但上面的行需要在执行 install mongodb-org 之后添加:

sudo yum install -y mongodb-org

答案3

刚刚找到了安装旧版本 mongoDB 的方法,但不是 v3.4。

尝试将此信息写入“/etc/yum.repo.d/mongodb.repo”:

[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
enabled=1

然后 yum 通过以下命令开始安装 mongodb-org-2.6.12:

sudo yum install mongodb-org

再次,它使我的应用程序正常工作,但我可能需要更新版本的 mongoDB。
安装 v3.4 有帮助吗?

答案4

mongodb-repo 在 CentOS 7 上对我不起作用。baseurl 似乎不存在。我用了

dnf install mongodb-server
dnf install mongodb

这在我的机器上安装了 3.4 版本。由于它是通过 进行配置的dnf,因此它应该会自动获取未来的更新。

相关内容