将自管理独立运行更改为WiredTiger
注意
您必须升级到 WiredTiger。MongoDB 移除了版本 4.2 中已弃用的 MMAPv1 storage engine。
Use this tutorial to change the storage engine of a 单节点 MongoDB instance to WiredTiger.
Considerations
mongodump
和 mongorestore
This tutorial uses the mongodump
and
mongorestore
utilities to export and import data.
默认绑定至本地主机
默认情况下,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
.
XFS 和 WiredTiger
对于 WiredTiger 存储引擎,建议在 Linux 上使用 XFS 作为数据承载节点。有关详情,请参阅内核和文件系统。
仅限于 MMAPv1 限制
升级到 WiredTiger 后,WiredTiger 部署不受以下仅限于 MMAPv1 限制的约束:
MMAPv1 限制 | 简短描述 |
---|---|
命名空间数 | 对于 MMAPv1,命名空间的数量限制为命名空间文件的大小除以 628。 |
命名空间文件的大小 | 对于 MMAPv1,命名空间文件的大小不得超过 2047 兆字节。 |
数据库大小 | MMAPv1 存储引擎将每个数据库限制为不超过 16000 个数据文件。 |
数据大小 | 对于 MMAPv1,单个 |
数据库中的集合数量 | 对于 MMAPv1 存储引擎,数据库中集合的最大数量是命名空间文件大小和数据库中集合索引数量的函数。 |
步骤
Start the mongod
you wish to change to WiredTiger.
If mongod
is already running, you can skip this step.
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.
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不会启动使用其他存储引擎创建的数据文件。
更新 WiredTiger 的配置。
从 mongod
实例配置中删除任何 MMAPv1 配置选项。
使用 WiredTiger 启动 mongod
。
开始 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
设置。
Upload the exported data using mongorestore
.
mongorestore <exportDataDestination>
Specify additional options as appropriate. See
mongorestore
for available options.