Note
- The
noPaddingandusePowerOf2SizesMMAPv1 options for thecollModcommand are removed. 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 update a replica set to use WiredTiger. The procedure updates the replica set in a rolling fashion to avoid downtime.使用本教程更新副本集以使用WiredTiger。该过程以滚动方式更新副本集,以避免停机。
Considerations注意事项
Replica sets can have members with different storage engines. As such, you can update members to use the WiredTiger storage engine in a rolling fashion.副本集可以包含具有不同存储引擎的成员。因此,您可以更新成员以滚动方式使用WiredTiger存储引擎。
PSA 3-member ArchitecturePSA三人架构
The 默认情况下,WiredTiger启用了"majority" read concern, available for WiredTiger, is enabled by default. "majority"读取关注。However, in three-member replica sets with a primary-secondary-arbiter (PSA) architecture, you can disable the 然而,在具有主从仲裁器(PSA)架构的三成员副本集中,您可以禁用"majority" read concern. "majority"读取关注。Disabling the 禁用三成员PSA架构的"majority" read concern for a three-member PSA architecture avoids possible cache-pressure build up."majority"读取关注可以避免可能的缓存压力积聚。
The procedure below disables 以下过程通过包含"majority" read concern for PSA architecture by including --enableMajorityReadConcern false.--enableMajorityReadConcern false来禁用PSA架构的"majority"读取关注。
Note
Disabling 禁用"majority" read concern has no effect on change streams availability."majority"读取关注不会影响更改流的可用性。
For more information on PSA architecture and read concern 有关PSA架构的更多信息,请读取关注"majority", see Primary-Secondary-Arbiter Replica Sets."majority",请参阅主从仲裁器副本集。
Default Bind to Localhost默认绑定到本地主机
MongoDB binaries, MongoDB二进制文件mongod and mongos, bind to localhost by default.mongod和mongos默认绑定到localhost。
XFS and 和WiredTiger
With the WiredTiger storage engine, using XFS for data bearing nodes is recommended on Linux. For more information, see Kernel and File Systems.对于WiredTiger存储引擎,建议在Linux上使用XFS作为数据承载节点。有关更多信息,请参阅内核和文件系统。
MMAPv1 Only Restrictions仅MMAPv1限制
Once upgraded to WiredTiger, your WiredTiger deployment is not subject to the following MMAPv1-only restrictions:升级到WiredTiger后,WiredTiger部署不受以下仅限MMAPv1的限制:
| MMAPv1 | |
|---|---|
mongod instance cannot manage a data set that exceeds maximum virtual memory address space provided by the underlying operating system.mongod实例无法管理超过底层操作系统提供的最大虚拟内存地址空间的数据集。 | |
Procedure过程
The following procedure updates the replica set in a rolling fashion. 以下过程以滚动方式更新副本集。The procedure updates the secondary members first, then steps down the primary, and updates the stepped-down member.该过程首先更新次要成员,然后逐步减少primary成员,并更新已减少的成员。
To update a member to WiredTiger, the procedure removes a member's data, starts 若要将成员更新为WiredTiger,该过程将删除成员的数据,使用WiredTiger启动mongod with WiredTiger, and performs an initial sync.mongod,并执行初始同步。
A. Update the secondary members to WiredTiger.将次要成员更新为WiredTiger。
Update the secondary members one at a time:一次更新一个次要成员:
Shut down the secondary member.关闭次要成员。
In 在mongosh, shut down the secondary.mongosh中,关闭secondary。
use admin
db.shutdownServer()Prepare a data directory for the new mongod running with WiredTiger.为使用WiredTiger运行的新mongod准备一个数据目录。
mongod running with WiredTiger.Prepare a data directory for the new 为将与WiredTiger存储引擎一起运行的新mongod instance that will run with the WiredTiger storage engine. mongod实例准备一个数据目录。mongod must have read and write permissions for this directory. You can either delete the contents of the stopped secondary member's current data directory or create a new directory entirely.mongod必须具有此目录的读写权限。您可以删除已停止的辅助成员当前数据目录的内容,也可以完全创建一个新目录。
带有WiredTiger的mongod with WiredTiger will not start with data files created with a different storage engine.mongod不会从使用不同存储引擎创建的数据文件开始。
Update configuration for WiredTiger.更新WiredTiger的配置。
Remove any MMAPv1 configuration options from the 从mongod instance configuration.mongod实例配置中删除所有MMAPv1配置选项。
Start mongod with WiredTiger.用WiredTiger开始mongod。
mongod with WiredTiger.Start 启动mongod, specifying wiredTiger as the --storageEngine and the prepared 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.至少,考虑启用身份验证并加强网络基础设施。
General Use (For Most Architectures)一般用途(适用于大多数架构)
mongod --storageEngine wiredTiger --dbpath <newWiredTigerDBPath> --replSet <replSetName> --bind_ip localhost,<hostname(s)|ip address(es)>PSA ArchitecturePSA架构
Important
If you are running a three-member PSA architecture, include 如果您正在运行一个由三个成员组成的PSA架构,请包含--enableMajorityReadConcern false to disable read concern majority. See PSA 3-member Architecture.--enableMajorityReadConcern false以禁用读取关注majority。请参阅PSA 3人架构。
mongod --storageEngine wiredTiger --dbpath <newWiredTigerDBPath> --replSet <replSetName> --bind_ip localhost,<hostname(s)|ip address(es)> --enableMajorityReadConcern falseSince no data exists in the 由于--dbpath, the mongod will perform an initial sync. --dbpath中没有数据,mongod将执行初始同步。The length of the initial sync process depends on the size of the database and network connection between members of the replica set.初始同步过程的长度取决于数据库的大小和副本集成员之间的网络连接。
You can also specify the options in a configuration file. 您还可以在配置文件中指定选项。To specify the storage engine, use the 要指定存储引擎,请使用storage.engine setting.storage.engine设置。
Repeat the steps for the remaining secondary members, updating them one at a time.对剩余的次要成员重复这些步骤,一次更新一个。
B. Step down the primary.退出primary。
Important
If updating all members of the replica set to use WiredTiger, ensure that all secondary members have been updated first before updating the primary.如果将副本集的所有成员更新为使用WiredTiger,请确保在更新主成员之前首先更新了所有辅助成员。
Once all the secondary members have been upgraded to WiredTiger, connect 一旦所有次要成员都升级到WiredTiger,将mongosh to the primary and use rs.stepDown() to step down the primary and force an election of a new primary.mongosh连接到主要成员,并使用rs.stepDown()退出主要成员并强制选举新的主要成员。
rs.stepDown()C. Update the stepped down primary.更新已降级的初选。
When the primary has stepped down and become a secondary, update the secondary to use WiredTiger as before:当主节点降级为次节点时,更新次节点以使用WiredTiger,如前所述:
Shut down the secondary member.关闭次要成员。
In 在mongosh, shut down the secondary.mongosh中,关闭secondary。
use admin
db.shutdownServer()Prepare a data directory for the new mongod running with WiredTiger.为使用WiredTiger运行的新mongod准备一个数据目录。
mongod running with WiredTiger.Prepare a data directory for the new 为将与WiredTiger存储引擎一起运行的新mongod instance that will run with the WiredTiger storage engine. mongod实例准备一个数据目录。mongod must have read and write permissions for this directory. You can either delete the contents of the stopped secondary member's current data directory or create a new directory entirely.mongod必须具有此目录的读写权限。您可以删除已停止的辅助成员当前数据目录的内容,也可以完全创建一个新目录。
mongod with WiredTiger will not start with data files created with a different storage engine.使用WiredTiger不会从使用其他存储引擎创建的数据文件开始。
Update configuration for WiredTiger.更新WiredTiger的配置。
Remove any MMAPv1 configuration options from the 从mongod instance configuration.mongod实例配置中删除所有MMAPv1配置选项。
Start mongod with WiredTiger.用WiredTiger开始mongod。
mongod with WiredTiger.Start 启动mongod, specifying wiredTiger as the --storageEngine and the prepared 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.至少,考虑启用身份验证并加强网络基础设施。
General Use (For Most Architectures)一般用途(适用于大多数架构)
mongod --storageEngine wiredTiger --dbpath <newWiredTigerDBPath> --replSet <replSetName> --bind_ip localhost,<hostname(s)|ip address(es)>PSA ArchitecturePSA架构
Important
If you are running a three-member PSA architecture, include 如果您正在运行一个由三个成员组成的PSA架构,请包含--enableMajorityReadConcern false to disable read concern majority. --enableMajorityReadConcern false以禁用读取关注majority。See PSA 3-member Architecture.请参阅PSA 3人架构。
mongod --storageEngine wiredTiger --dbpath <newWiredTigerDBPath> --replSet <replSetName> --bind_ip localhost,<hostname(s)|ip address(es)> --enableMajorityReadConcern falseSince no data exists in the 由于--dbpath, the mongod will perform an initial sync. --dbpath中没有数据,mongod将执行初始同步。The length of the initial sync process depends on the size of the database and network connection between members of the replica set.初始同步过程的长度取决于数据库的大小和副本集成员之间的网络连接。
You can also specify the options in a configuration file. 您还可以在配置文件中指定选项。To specify the storage engine, use the 要指定存储引擎,请使用storage.engine setting.storage.engine设置。