---
category: help
layout: help
mirrorid: mongodb
---

# MongoDB 软件仓库镜像使用帮助

<form class="form-inline">
<div class="form-group">
	<label>是否使用 HTTPS</label>
	<select id="http-select" class="form-control content-select" data-target="#content-0,#content-1,#content-2,#content-3,#content-4">
	  <option data-http_protocol="https://" selected>是</option>
	  <option data-http_protocol="http://">否</option>
	</select>
</div>
</form>


<form class="form-inline">
<div class="form-group">
	<label>是否使用 sudo</label>
	<select id="sudo-select" class="form-control content-select" data-target="#content-0,#content-1,#content-2,#content-3,#content-4">
	  <option data-sudo="sudo " selected>是</option>
	  <option data-sudo="">否</option>
	</select>
</div>
</form>



MongoDB 镜像自 MongoDB [官方仓库](https://repo.mongodb.org/)，目前有 RHEL/CentOS, Ubuntu, Debian 的镜像，支持 amd64, i386, arm64 架构。

更详细的内容，可以参考 [官方文档](https://docs.mongodb.org/master/administration/install-on-linux/)

### Debian/Ubuntu 用户

首先信任 MongoDB 的 GPG 公钥：



<form class="form-inline">
<div class="form-group">
  <label>MongoDB 版本号：</label>
    <select id="select-0-0" class="form-control content-select" data-target="#content-0">
      <option data-version="6.0" selected>6.0</option>
      <option data-version="5.0">5.0</option>
      <option data-version="4.4">4.4</option>
      <option data-version="4.2">4.2</option>
    </select>
</div>
</form>

{% raw %}
<script id="template-0" type="x-tmpl-markup">
wget -qO - https://www.mongodb.org/static/pgp/server-{{version}}.asc | {{sudo}}apt-key add -
</script>
{% endraw %}

<p></p>

<pre>
<code id="content-0" data-template="#template-0" data-select="#http-select,#sudo-select,#select-0-0">
</code>
</pre>


再选择你的 Debian / Ubuntu 版本，文本框中内容写进 `/etc/apt/sources.list.d/mongodb.list`



<form class="form-inline">
<div class="form-group">
  <label>发行版：</label>
    <select id="select-1-0" class="form-control content-select" data-target="#content-1">
      <option data-os_name="debian" data-release_name="bullseye" data-component_name="main" selected>Debian 11</option>
      <option data-os_name="debian" data-release_name="buster" data-component_name="main">Debian 10</option>
      <option data-os_name="debian" data-release_name="stretch" data-component_name="main">Debian 9</option>
      <option data-os_name="debian" data-release_name="jessie" data-component_name="main">Debian 8</option>
      <option data-os_name="ubuntu" data-release_name="jammy" data-component_name="multiverse">Ubuntu 22.04 LTS</option>
      <option data-os_name="ubuntu" data-release_name="focal" data-component_name="multiverse">Ubuntu 20.04 LTS</option>
      <option data-os_name="ubuntu" data-release_name="bionic" data-component_name="multiverse">Ubuntu 18.04 LTS</option>
      <option data-os_name="ubuntu" data-release_name="xenial" data-component_name="multiverse">Ubuntu 16.04 LTS</option>
    </select>
</div>
</form>

<form class="form-inline">
<div class="form-group">
  <label>MongoDB 版本号：</label>
    <select id="select-1-1" class="form-control content-select" data-target="#content-1">
      <option data-version="6.0" selected>6.0</option>
      <option data-version="5.0">5.0</option>
      <option data-version="4.4">4.4</option>
      <option data-version="4.2">4.2</option>
    </select>
</div>
</form>

{% raw %}
<script id="template-1" type="x-tmpl-markup">
deb {{http_protocol}}{{mirror}}/apt/{{os_name}} {{release_name}}/mongodb-org/{{version}} {{component_name}}
</script>
{% endraw %}

<p></p>

<pre>
<code id="content-1" data-template="#template-1" data-select="#http-select,#sudo-select,#select-1-0,#select-1-1">
</code>
</pre>


安装 `mongodb-org` 即可



{% raw %}
<script id="template-2" type="x-tmpl-markup">
{{sudo}}apt-get update
{{sudo}}apt-get install -y mongodb-org
</script>
{% endraw %}

<p></p>

<pre>
<code id="content-2" data-template="#template-2" data-select="#http-select,#sudo-select">
</code>
</pre>


### RHEL/CentOS 用户


新建 `/etc/yum.repos.d/mongodb.repo`，内容为



{% raw %}
<script id="template-3" type="x-tmpl-markup">
[mongodb-org]
name=MongoDB Repository
baseurl={{http_protocol}}{{mirror}}/yum/el$releasever/
gpgcheck=0
enabled=1
</script>
{% endraw %}

<p></p>

<pre>
<code id="content-3" data-template="#template-3" data-select="#http-select,#sudo-select">
</code>
</pre>


刷新缓存并安装 `mongodb-org` 即可。



{% raw %}
<script id="template-4" type="x-tmpl-markup">
{{sudo}}yum makecache
{{sudo}}yum install mongodb-org
</script>
{% endraw %}

<p></p>

<pre>
<code id="content-4" data-template="#template-4" data-select="#http-select,#sudo-select">
</code>
</pre>


