Docs 菜单

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

注意

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

Use this tutorial to change the storage engine of a 单节点 MongoDB instance to WiredTiger.

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

  • Ensure that these MongoDB package components are installed and updated on your system.

  • 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 二进制文件 mongodmongos 绑定到 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

If mongod is already running, you can skip this step.

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

Create a data directory for the new mongod instance that will run with the WiredTiger storage engine. mongod must have read and write permissions for this directory.

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

4

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

5

开始 mongod, specifying wiredTiger as the --storageEngine and the newly created data directory for WiredTiger as the --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.