Note
Starting in version 4.2, MongoDB removes the deprecated MMAPv1 storage engine. If upgrading to MongoDB 4.2 from a MongoDB 4.0 deployment that uses MMAPv1, you must upgrade to WiredTiger.
Use this tutorial to change the storage engine of a standalone MongoDB instance to WiredTiger.
mongodump
and mongorestore
¶This tutorial uses the mongodump
and mongorestore
utilities to export and import data.
Starting with MongoDB 3.6, MongoDB binaries, mongod
and mongos
, bind to localhost
by default. From MongoDB versions 2.6 to 3.4, only the binaries from the official MongoDB RPM (Red Hat, CentOS, Fedora Linux, and derivatives)
and DEB (Debian, Ubuntu, and derivatives) packages would bind to localhost
by default. To learn more about this change, see Localhost Binding Compatibility Changes.
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
.
With the WiredTiger storage engine, using XFS for data bearing nodes is recommended on Linux. For more information, see Kernel and File Systems.
Once upgraded to WiredTiger, your WiredTiger deployment is not subject to the following MMAPv1-only restrictions:
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. |
Size of Namespace File | For MMAPv1, namespace files can be no larger than 2047 megabytes. |
Database Size | The MMAPv1 storage engine limits each database to no more than 16000 data files. |
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. |
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. |
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.
Remove any MMAPv1 Specific Configuration Options from the mongod
instance configuration.
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, such as --bind_ip
.
Warning
Before binding to a non-localhost (e.g. publicly accessible) IP address, ensure you have secured your cluster from unauthorized access. For a complete list of security recommendations, see Security Checklist. At minimum, consider enabling authentication and hardening network infrastructure.
You can also specify the options in a configuration file. To specify the storage engine, use the storage.engine
setting.
mongorestore
.¶Specify additional options as appropriate. See mongorestore
for available options.