Navigation and service panel


Content

Activate the Tiger in your xDB

By Reto Hugi on 19. May 2015, 1 Comment

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.

YAML Configuration

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:
    destination: file
    path: "C:\\MongoDB\\log\\mongod.log"
    logAppend: true
storage:
    dbPath: "C:\\MongoDB\\db"
    directoryPerDB: true
    engine: wiredTiger
    wiredTiger:
        engineConfig:
            directoryForIndexes: true
        collectionConfig:
            blockCompressor: zlib

While the systemLog section is easy and nothing new, the storage section contains interesting parts.

Directory Structure

When you start the MongoDB service (aka mongod) with storage.wiredTiger.engineConfig.directoryForIndexes, mongod stores indexes and collections in separate directories. The setting storage.directoryPerDB is available with the default storage engine, but if you use wiredTiger, you have to set the storage.wiredTiger.engineConfig.directoryForIndexes.

This is how the filesystem structure looks like after applying these settings:

MongoDB with directoryPerDB set to true

Compression

The 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.

Related Notes

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.

Categories  Configuration Tags  MongoDB  xDB  Setup

1 Comment

  1. 1. June 2015 at 14:20

    Excellent post :) I prefer not having MongoDb running all the time, therefor I haven't installed it as a service. Also I like to organise my databases in the same path as the SQL databases are (these are mostly in the same directory as the data and website directory of my Sitecore instance). I start MongoDb every time I need it with a batch file descirbed here: https://briancaos.wordpress.com/2014/10/01/sitecore-and-xdb-setting-up-mongodb-on-your-developer-machine/. The only issue with this is, that I always forget to start it ;-)

Add your comment

Your email address will not be published. Required fields are marked *

*