Database Manual / Self-Managed Deployments / Storage / Storage Engines / WiredTiger

Change a Self-Managed Standalone to WiredTiger将自管理独立设备更改为WiredTiger

Note

You must upgrade to WiredTiger. MongoDB removed the deprecated MMAPv1 storage engine in version 4.2.您必须升级到WiredTiger。MongoDB在4.2版本中删除了弃用的MMAPv1存储引擎。

Use this tutorial to change the storage engine of a standalone MongoDB instance to WiredTiger.使用本教程将独立MongoDB实例的存储引擎更改为WiredTiger。

Considerations注意事项

mongodump and mongorestore

This tutorial uses the mongodump and mongorestore utilities to export and import data.本教程使用mongodumpmongorestore实用程序导出和导入数据。

  • Ensure that these MongoDB package components are installed and updated on your system.确保在系统上安装并更新了这些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.确保您有足够的驱动器空间用于mongodump导出文件和使用WiredTiger运行的新mongod实例的数据文件。

Default Bind to Localhost默认绑定到本地主机

MongoDB binaries, mongod and mongos, bind to localhost by default.MongoDB二进制文件mongodmongos默认绑定到localhost

The tutorial runs mongodump and mongorestore from the same host as the mongod they are connecting to. 本教程从与它们连接的mongod相同的主机运行mongodumpmongorestoreIf run remotely, mongodump and mongorestore must specify the ip address or the associated hostname in order to connect to the mongod.如果远程运行,mongodumpmongorestore必须指定ip地址或相关主机名才能连接到mongod

XFS and WiredTiger

With the WiredTiger storage engine, using XFS for data bearing nodes is recommended on Linux. 对于WiredTiger存储引擎,建议在Linux上使用XFS作为数据承载节点。For more information, see Kernel and File Systems.有关更多信息,请参阅内核和文件系统

MMAPv1 Only Restrictions仅限限制

Once upgraded to WiredTiger, your WiredTiger deployment is not subject to the following MMAPv1-only restrictions:升级到WiredTiger后,WiredTiger部署不受以下仅限MMAPv1的限制:

MMAPv1 Restrictions限制Short Description简短描述
Number of Namespaces命名空间数量For MMAPv1, the number of namespaces is limited to the size of the namespace file divided by 628.对于MMAPv1,命名空间的数量限制为命名空间文件的大小除以628。
Size of Namespace File命名空间文件的大小For MMAPv1, namespace files can be no larger than 2047 megabytes.对于MMAPv1,命名空间文件不能大于2047 MB。
Database Size数据库大小The MMAPv1 storage engine limits each database to no more than 16000 data files.MMAPv1存储引擎将每个数据库限制为不超过16000个数据文件。
Data Size数据大小For MMAPv1, a single mongod instance cannot manage a data set that exceeds maximum virtual memory address space provided by the underlying operating system.对于MMAPv1,单个mongod实例无法管理超过底层操作系统提供的最大虚拟内存地址空间的数据集。
Number of Collections in a Database数据库中的集合数For the MMAPv1 storage engine, the maximum number of collections in a database is a function of the size of the namespace file and the number of indexes of collections in the database.对于MMAPv1存储引擎,数据库中集合的最大数量是命名空间文件大小和数据库中集合索引数量的函数。

Procedure过程

1

Start the mongod you wish to change to WiredTiger.启动您要更改为WiredTiger的mongod

If mongod is already running, you can skip this step.如果mongod已经在运行,则可以跳过此步骤。

2

Export data using mongodump.使用mongodump导出数据。

mongodump --out=<exportDataDestination>

Specify additional options as appropriate, such as username and password if running with authorization enabled. 根据需要指定其他选项,例如在启用授权的情况下运行时的用户名和密码。See mongodump for available options.有关可用选项,请参阅mongodump

3

Create a data directory for the new mongod running with WiredTiger.为使用WiredTiger运行的新mongod创建一个数据目录。

Create a data directory for the new mongod instance that will run with the WiredTiger storage engine. 为将与WiredTiger存储引擎一起运行的新mongod实例创建一个数据目录。mongod must have read and write permissions for this directory.mongod必须具有此目录的读写权限。

mongod with WiredTiger will not start with data files created with a different storage engine.带有WiredTiger的mongod不会从使用不同存储引擎创建的数据文件开始。

4

Update configuration for WiredTiger.更新WiredTiger的配置。

Remove any MMAPv1 configuration options from the mongod instance configuration.mongod实例配置中删除所有MMAPv1配置选项。

5

Start mongod with WiredTiger.用WiredTiger开始mongod

Start mongod, specifying wiredTiger as the --storageEngine and the newly created data directory for WiredTiger as the --dbpath.启动mongod,将wiredTiger指定为--storageEngine,将新创建的wiredTiger数据目录指定为--dbpath

Specify additional options as appropriate, such as --bind_ip.根据需要指定其他选项,例如--bind_ip

Warning

Before you bind your instance to a publicly-accessible IP address, you must secure your cluster from unauthorized access. 在将实例绑定到可公开访问的IP地址之前,必须保护集群免受未经授权的访问。For a complete list of security recommendations, see Security Checklist for Self-Managed Deployments. 有关安全建议的完整列表,请参阅自我管理部署的安全检查表At minimum, consider enabling authentication and hardening network infrastructure.至少,考虑启用身份验证加强网络基础设施

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

You can also specify the options in a configuration file. 您还可以在配置文件中指定选项。To specify the storage engine, use the storage.engine setting.要指定存储引擎,请使用storage.engine设置。

6

Upload the exported data using mongorestore.使用mongorestore上传导出的数据。

mongorestore <exportDataDestination>

Specify additional options as appropriate. 根据需要指定其他选项。See mongorestore for available options.有关可用选项,请参阅mongorestore