- Storage >
- Storage Engines >
- WiredTiger Storage Engine >
- Change Replica Set to WiredTiger
Change Replica Set to WiredTiger¶
Starting in version 3.2, WiredTiger is the default storage engine for MongoDB.
This tutorial gives an overview of changing the storage engine of a replica set member to 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.
MongoDB 3.0 or Greater¶
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.
Procedure¶
To update a member to WiredTiger, the procedure removes a member’s
data, starts mongod with WiredTiger, and performs an
initial sync.
Tip
To update all members of the replica set to use WiredTiger, update
the members in a rolling manner. That is, update, one by one, all
secondary members first. Then, once all the secondary
members have been updated, step down the
primary, and update that stepped-down member.
Update a secondary member.¶
Prepare a data directory for the new mongod running with WiredTiger.¶
Prepare 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. You can either delete the
contents of the stopped secondary member’s current data directory or
create a new directory entirely.
mongod with WiredTiger will not start with data files created with
a different storage engine.
Start mongod with WiredTiger.¶
Start mongod, specifying wiredTiger as the
--storageEngine and the prepared data directory for
WiredTiger as the --dbpath. Specify additional options
as appropriate for this replica set
member.
Since no data exists in the --dbpath, the mongod will perform an
initial sync. 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.
To update another secondary, repeat the previous steps.
Update the 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.
To update the primary, step down the
primary.
When the primary has stepped down and become a secondary, update the secondary to use WiredTiger as before:
Prepare a data directory for the new mongod running with WiredTiger.¶
Prepare 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. You can either delete the
contents of the stopped secondary member’s current data directory or
create a new directory entirely.
mongod with WiredTiger will not start with data files created with
a different storage engine.
Start mongod with WiredTiger.¶
Start mongod, specifying wiredTiger as the
--storageEngine and the prepared data directory for
WiredTiger as the --dbpath. Specify additional options
as appropriate for this replica set
member.
Since no data exists in the --dbpath, the mongod will perform an
initial sync. 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.