Switching Storage Engines¶
By default, Percona Server for MongoDB runs with WiredTiger. There is also the original MMAPv1 storage engine, as well as optional Percona Memory Engine and MongoRocks storage engines to choose from. Each one is designed for specific purposes and workloads.
You can select a storage engine
--storageEngine command-line option when you start
Alternatively, you can set the
in the configuration file (by default,
Data created by one storage engine is not compatible with other storage engines, because each one has its own data model. When changing the storage engine, you have to do one of the following:
If you simply want to temporarily test a storage engine, you can change to a different data directory using the
$ service mongod stop $ mongod --storageEngine rocksdb --dbpath <dataDirForRocksDB>
Make sure that the user running
mongodhas read and write permissons for the new data directory.
If you want to permanently switch to a different storage engine and do not have any valuable data in your database, clean out the default data directory and edit the configuration file:
$ service mongod stop $ rm -rf /var/lib/mongodb/* $ sed -i '/engine: \*rocksdb/s/#//g' /etc/mongod.conf $ service mongod start
If there is data that you want to migrate and make compatible with the new storage engine, use the
$ mongodump --out <dumpDir> $ service mongod stop $ rm -rf /var/lib/mongodb/* $ sed -i '/engine: \*rocksdb/s/#//g' /etc/mongod.conf $ service mongod start $ mongorestore <dumpDir>
Storage Engine Configuration Templates¶
The default configuration file provided with Percona Server for MongoDB (
contains templates for running any of the bundled storage engine.
The suggested values do not cover all cases,
but they are a good reference point to start customizing the configuration.
The following hints may help you:
- On very high volume systems,
you may need to increase the maximum number of concurrent transactions
for WiredTiger and Percona Memory Engine (default is 128).
These are controlled using the following MongoDB parameters:
- On systems with more than roughly 24,000 collections running MMAPv1,
- Also for MMAPv1 you can set
trueto use a smaller default file size, if you have a large number of databases that each holds a small amount of data.
storage.rocksdb.countersvariable must be set to
trueif you are running MongoRocks and want to use Percona Monitoring and Management.
- The default maximum internal cache size that WiredTiger uses
is the larger of either:
- 50% of RAM minus 1 GB
- 256 MB
- The default maximum internal cache size that MongoRocks uses is 30% of RAM.