在 AWS linux 上通过 yum 安装 MongoDB 失败:HTTPS 错误 404 - 未找到

Installing MongoDB via yum on AWS linux fails: HTTPS Error 404 - Not Found

我试图按照 MongoDB Doc 上的步骤通过 yum 在我的服务器上安装 mongodb@3.4。首先,我在 /etc/yum.repos.d/ 中创建了一个名为 mongodb-org-3.4.repo 的文件 目录并复制如下文本。

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

然后我尝试 sudo yum install mongodb-org 但出现错误。

Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main                             | 2.1 kB     00:00
amzn-updates                          | 2.3 kB     00:00
https://repo.mongodb.org/yum/redhat/latest/mongodb-org/3.4/x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below knowledge base article

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.



One of the configured repositories failed (MongoDB),
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. Disable the repository, 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

4. 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/latest/mongodb-org/3.4/x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found

之后,我试了yum repolist,发现MongoDB的状态得到0。

Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main                             | 2.1 kB     00:00
amzn-updates                          | 2.3 kB     00:00
https://repo.mongodb.org/yum/redhat/latest/mongodb-org/3.4/x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below knowledge base article

https://access.redhat.com/articles/1320623

If above article doesn't help to resolve this issue please open a ticket with Red Hat Support.

https://repo.mongodb.org/yum/redhat/latest/mongodb-org/3.4/x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
nodesource/x86_64                     | 2.5 kB     00:00
repo id                repo name                       status
amzn-main/latest       amzn-main-Base                  5,668
amzn-updates/latest    amzn-updates-Base                 435
mongodb-org-3.4/latest MongoDB                             0
nodesource/x86_64      Node.js Packages for Enterprise    61
repolist: 6,164 

我想知道那个 repo 是否仍然有效?谢谢~

这是我的服务器 OS 版本:

NAME="Amazon Linux AMI"
VERSION="2017.03"
ID="amzn"
ID_LIKE="rhel fedora"
VERSION_ID="2017.03"
PRETTY_NAME="Amazon Linux AMI 2017.03"
ANSI_COLOR="0;33"
CPE_NAME="cpe:/o:amazon:linux:2017.03:ga"
HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
Amazon Linux AMI release 2017.03

请试试这个,

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

sudo yum clean all

再次创建回购文件

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

[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/amazon/2013.03/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

更新为March/2018

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

添加(或替换)mongo 存储库配置:

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

现在,您可以

yum repolist

sudo yum install -y mongodb-org

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

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

但执行安装后需要添加以上行 mongodb-org:

sudo yum install -y mongodb-org

因此,从 /etc/yum.conf 中删除 exclude 行以使 mongodb-org 包可用