Getting started – Mongo and xDB part one

With the release of Sitecore 7.5 we saw the introduction of NoSQL to the Sitecore ecosystem. Sitecores platform of choice is MongoDB, an open source document database that runs as a separate server. MongoDB stores all of its data as memory mapped files in a format very similar to JSON (called BSON).

By default, Sitecore Analytics now requires both SQL Server and MongoDB to operate. MongoDB provides much of the data capture and storage and SQL Server the aggregation of that data. Additionally, the ECM and WFFM for Sitecore 7.5 now also use the xDB platform and so also use MongoDB by default.

Its worth knowing this as any implementation of Sitecore 7.5 (or an upgrade to it) will need the infrastructure to support a Mongo installation. Reading through the xDB documentation, it isn’t immediately clear what is required of an xDB infrastructure and it does require quite a bit of background reading. This first post, of a series, is intended to give you a background in some of the items you’ll need to be aware of and also how this relates to Sitecore.

I’ll keep much of the details here focused but necessarily light as more information is available on the Mongo website.

Installing Mongo for development

There are a lot of concepts to take in when using Mongo. But its probably best to just go and install it first and see it in action under simple, developer conditions.

To that end, you will need the following:

  • Mongo download for your platform. 64bit is preferred
  • If on windows, check the Mongo documentation to determine if you need the Windows hotfix
  • Administrator privileges to install new software

There is a bug in a few versions of Windows which means the way Mongo accesses files can be affected. You must install this hotfix on all workstations and target servers before running Mongo. So if your servers are affected, you must plan for some downtime.

When I install Mongo, I try to keep everything in standard locations and have a common configuration file. I also have a separate folder per Mongo database. A sample configuration file is below.

   dbPath: "/mongo-data/db"
   directoryPerDB: true
   destination: file
   path: "/mongo-data/logs/mongod.log"
   logAppend: false
   verbosity: 3

Obviously feel free to edit for your own purposes. I also add the Mongo installation folder to my path so I can use the tools more easily from my command line. For the Mongo server, I install it as a service like following:

mongod -f c:\mongo-data\mongod.config --install

And then I can run it via ‘net start mongodb’.

Setting up Mongo with Sitecore

The xDB documentation refers to editing the connectionstrings configuration file. At first this might be a bit confusing as there are no backup files to restore as you would with SQL Server. These databases are created on demand the first time you fire up the Sitecore server. At the time of writing these are:

  • analytics
  • tracking-history
  • tracking-live

These are configured as follows (for default options):

  <add name="analytics" connectionString="mongodb://localhost/analytics" />
  <add name="" connectionString="mongodb://localhost/tracking-live" />
  <add name="tracking.history" connectionString="mongodb://localhost/tracking-history" />

To view them, you can run the Mongo shell and type ‘show dbs’. For a production systen, these databases may well be on separate servers so you would have to inspect each one. Alternatively, I recommend you check out Robomongo which is a free GUI for Linux, Mac and Windows.

At this stage, everything is quite simple. We have a running Mongo instance as a windows service with default settings to allow our developer installation of Sitecore to connect to it. In a future post I’ll cover the specifics of having replication and data partitioning for these databases and what this means for a UAT or production environment.

In my next post I’ll go more into simple security for a developer workstation, practising some basic queries as well as think about taking backups.

2 thoughts on “Getting started – Mongo and xDB part one

    • Hey Bill,

      It wasn’t myself who wrote this post, but I am afraid I don’t know the answer to your question. Have been running Windows 8 & Server 2012 for some time now.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s