The goal of this post is to outline the steps to connect a Sitecore instance to MongoLab for xDB tracking and analytics. With the introduction of the xDB, tracking and analytics have moved from a dedicated SQL instance with DMS, to a fire-and-forget model in xDB with Mongo.
There is a very helpful article on Sitecore’s main site outlining the steps to deploy Sitecore 8 on Azure, with references to MongoLab. Reference that article for a full walk-through to deploy to Azure.
MongoLab offers a terrific solution if you’re looking to move your data collection to a hosted offering, one in which you can easily scale without having to worry about in-house support and maintenance. This holds especially true for those considering moving to a cloud-hosted solution for Sitecore content delivery, such as Microsoft Azure.
Create a MongoLab Account
Go to www.mongolab.com and create an account. You may choose a pricing plan, or for those of you who are testing this configuration, move forward with a Sandbox environment with data allocations of up to 500 MB.
Create MongoLab Databases
Creating each database is simple. Click on the Create New button and follow the options to setup and configure your database.
I chose Windows Azure for the cloud provider, since I’m hosting my sandbox Sitecore 8 instance in Azure. I want to also keep my MongoLab deployment instances in the same location as my cloud service Sitecore 8 instance (East US) and chose the Single-Node plan, as this is simply a Sandbox implementation.
You may choose from one of the many options on the Replica set cluster side, as these options offer complete failover support for production instances. Note that after choosing the initial configuration, scaling should not be a problem if you eventually need to expand your MongoLab instance.
Choose version 2.6.x or later if using Sitecore 8.
For each database name, follow a similar naming convention for all of your databases. Remember these database names, as these will be applied to both your CE and CD connection strings.
For this example, I created entries for each of the following databases:
- Analytics (required for content delivery)
- Tracking Contact (required for content delivery)
- Tracking Live (required for content delivery)
- Tracking History (required for content editing)
Note: See Sitecore’s recommendation for configuring MongoDB as your session provider
After creating your databases, you should see a similar list of MongoDB deployments:
Much like configuring SQL Server databases, you will need to create a user for each database. You can create new users by clicking on the Add database user button. Choose a password and set read/write access. Remember your password, as this will be applied to the Mongo connection URI.
Setup Connection Strings
Upon successfully creating your databases and related users, you can click on each database instance to see examples on how to connect to your new MongoLab database:
Copy the URI from the To connect using a driver via the standard URI and update you connection strings file. Your connection strings should resemble the following:
Test Your Connection
From there, your instance (whether cloud-service based or on-prem) will spin up and communicate with your new MongoLab databases. At that point, your MongoLab database collections will start to auto-generate, just as they would with any non-hosted mongo solution. Looking back at the Analytics MongoLab database, for example, you should see collections resembling the following:
Total setup time can be anywhere from 15-30 minutes. MongoLab’s interface is quite simple and makes configuration a breeze.