翻译或纠错本页面

将单机模式下的 MongoDB 存储引擎切换到WiredTiger

3.0 新版功能: WiredTiger 引擎目前是可用的.

在 3.2 版更改: 在 MongoDB 最新版本中, WiredTiger 作为默认引擎出现.

这篇文档告诉你, 如何将单机模式的 standalone MongoDB 实例的存储引擎切换到 WiredTiger.

注意事项

这篇教程使用 mongodumpmongorestore 工具用来对数据进行导出导入. 确保这些 MongoDB 组件在你的系统中有安装并且进行了更新.另外, 要保证你的磁盘空间足够容纳 mongodump 导出的数据和新的使用 WiredTiger 引擎的 mongod 实例数据.

要使用 WiredTiger 引擎, MongoDB 版本必须为 3.0 或以上. 如果需要从更低版本的 MongoDB 升级, 在更改存储引擎之前, 需要参考 升级到 MongoDB 3.0 或者 升级到 MongoDB 3.2.

步骤

1

Start the mongod you wish to change to WiredTiger.

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

2

Export data using mongodump.

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 running with WiredTiger.

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 will not start with data files created with a different storage engine.

4

Start mongod with WiredTiger.

Start mongod, specifying wiredTiger as the --storageEngine and the newly created data directory for WiredTiger as the --dbpath. Specify additional options as appropriate.

mongod --storageEngine wiredTiger --dbpath <newWiredTigerDBPath>

You can also specify the options in a configuration file. To specify the storage engine, use the storage.engine setting.

5

Upload the exported data using mongorestore.

mongorestore <exportDataDestination>

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