With Sitecore 7.5 and 8 you probably added MongoDB to your dev environment. And if you’re running a lot of different instances and you would like to keep the MongoDB DB directory organised, this post is for you.
MongoDB 3.0 introduces a lot of exciting new features. Among others, it supports pluggable storage engines and includes wiredTiger as a new option.
For my local dev environment I was especially interested in compression and storage structure on the filesystem. With sometimes more than 20 playgrounds running with defaults for xDB, the created DBs make the DB directory quite messy. So here is my simple mongod.cfg in YAML format:
systemLog section is easy and nothing new, the
storage section contains interesting parts.
When you start the MongoDB service (aka
mongod stores indexes and collections in separate directories.
storage.directoryPerDB is available with the default storage engine, but if you use wiredTiger, you have to set the
This is how the filesystem structure looks like after applying these settings:
storage.wiredTiger.collectionConfig.blockCompressor setting affects all collections created. If you change its value on an existing MongoDB deployment, all new collections will use the specified compressor.
While “snappy” is the default value for compression and provides already a very good average rate of 70%, zlib should improve compression even further. Therefore I set the compression algorithm to zlib. Please note, that already created databases will keep their compression setting.
For more details on the configuration options I found the official documentation a good read.
These settings will break setups with already created databases based on the default MMAPv1 storage engine. You can either go to your local db directory and clear it entirely (it is a local setup after all) or switch the storage engine by dumping and importing the data through
mongodump. Details are documented in the 3.0 upgrade guide.
Another important thing to know: by the time of this writing wiredTiger is not supported by MongoVue and Robomongo. MongoChef seems to be the only third party admin tool supporting wiredTiger so far.