对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

将自管理独立运行更改为WiredTiger

注意

您必须升级到 WiredTiger。MongoDB 移除了版本 4.2 中已弃用的 MMAPv1 storage engine。

使用本教程将独立 MongoDB 实例的存储引擎更改为 WiredTiger。

This tutorial uses the mongodump and mongorestore utilities to export and import data.

  • 确保在系统中安装并更新了这些 MongoDB 程序包组件。

  • Make sure you have sufficient drive space available for the mongodump export file and the data files of your new mongod instance running with WiredTiger.

默认情况下,MongoDB 二进制文件 mongod 和 mongos 绑定到 localhost。

The tutorial runs mongodump and mongorestore from the same host as the mongod they are connecting to. If run remotely, mongodump and mongorestore must specify the ip address or the associated hostname in order to connect to the mongod.

对于 WiredTiger 存储引擎,建议在 Linux 上使用 XFS 作为数据承载节点。有关详情,请参阅内核和文件系统。

升级到 WiredTiger 后,WiredTiger 部署不受以下仅限于 MMAPv1 限制的约束:

MMAPv1 限制
简短描述

命名空间数

对于 MMAPv1,命名空间的数量限制为命名空间文件的大小除以 628。

命名空间文件的大小

对于 MMAPv1,命名空间文件的大小不得超过 2047 兆字节。

数据库大小

MMAPv1 存储引擎将每个数据库限制为不超过 16000 个数据文件。

数据大小

对于 MMAPv1,单个 mongod 实例管理的数据集不能超过底层操作系统提供的最大虚拟内存地址空间。

数据库中的集合数量

对于 MMAPv1 存储引擎,数据库中集合的最大数量是命名空间文件大小和数据库中集合索引数量的函数。

1

如果 mongod 已经运行,则可以跳过此步骤。

2
mongodump --out=<exportDataDestination>

Specify additional options as appropriate, such as username and password if running with authorization enabled. See mongodump for available options.

3

为将使用 WiredTiger 存储引擎运行的新 mongod 实例创建一个数据目录。mongod 必须具有此目录的读写权限。

mongod 带有 WiredTiger,不会启动使用其他存储引擎创建的数据文件。

4

从 mongod 实例配置中删除任何 MMAPv1 配置选项。

5

启动 mongod,指定 wiredTiger 为 --storageEngine,为 WiredTiger 新建的数据目录为 --dbpath。

根据需要指定其他选项,如 --bind_ip。

警告

将实例绑定到可公开访问的 IP 地址之前,必须保护集群免遭未经授权的访问。有关安全建议的完整列表,请参阅自管理部署的安全清单。至少应考虑启用身份验证和强化网络基础设施。

mongod --storageEngine wiredTiger --dbpath <newWiredTigerDBPath> --bind_ip localhost,<hostname(s)|ip address(es)>

您也可以在配置文件中指定这些选项。要指定存储引擎,请使用 storage.engine 设置。

6
mongorestore <exportDataDestination>

Specify additional options as appropriate. See mongorestore for available options.

给本页内容打分