Sitecore introduced MongoDB in it’s ecosystem to solve the problem of scaling analytics, let’s try to understand MongoDB from Sitecore prespective, and see how it’s useful and where exactly it sit in the Sitecore system, we will have series of three posts where we will start with the introduction about it, it’s features, advantages, setting up MongoDB in your environment.
In the second series we will talk about contacts and some of the out of the box queries, and will to understand MongoDB collection, and in the final post we will see how we can create custom facets to extend MongoDB functionality.
Introduction to MongoDB
Sitecore 7.5 introduced MongoDB as the main datastore for the Sitecore Experience Database (xDB). Sitecore xDB allows organizations to collect all of their customer interactions from all channels to create a comprehensive, single view of the customer that allows marketers to better optimize the customer experience in real-time.
Following are some of the features of MongoDB:
- Open source
- Document oriented database.
- Primarily used for collecting data and information about visitors(for analytics)
- Visitors and their interactions are written to MongoDB in JSON format, which then processed by an aggregation pipeline into a format that is used for reporting.
There are several advantages and benefits with MongoDB, some of them are listed below:
- Standalone environment
- Vertical Scaling and
- Horizontal Scaling
- Unstructured data and Schemas
Scaling is one of the critical feature in Sitecore, and we will discuss about all different scaling options in the next series of this post, where we will talk more about horizontal scaling and how MongoDB uses it to make sure the availability of data.
Let’s take a look, how you can install MongoDB:
Please follow the below steps, to install MongoDB.
- Download MongoDB as per your Sitecore version, you can see more details here: https://doc.sitecore.net/sitecore_experience_platform/setting_up_and_maintaining/xdb/platform/software_recommendations and
- Next, you need to install Mongo, you can do it either in default installation path (C:\Program Files\MongoDB\Server\mongo version), or in custom path like (D:\Mongo\..)
- Create data and db folder:
- C:\Program Files\MongoDB\Server\3.0\data
- This folder is not created by default during installation, we need to install this.
- Once this folder is create, please create db folder under this.
- Create logs folder:
- C:\Program Files\MongoDB\Server\3.0\logs
- We can create a new config file where we specify db and logs folder, and this file will be used to install MongoDB as a service, so that it will start everytime when we start/boot windows.
- In this example, I have created a new folder “config” and added config file under that.
- C:\Program Files\MongoDB\Server\3.0\config
- Please use the below snippet and save make sure to change the db and log location, as per your environment location.
- C:\Program Files\MongoDB\Server\3.0\config\mongod-3.0.cfg
- Open up a Command Prompt (Run As Administrator), and navigate to bin folder
- C:\Program Files\MongoDB\Server\3.0\bin
- Run the following command to create MongoDB as a service:
- mongod –config=”C:\Program Files\MongoDB\Server\3.0\config\mongod-3.0.cfg” –install –serviceName=”MongoDB 3.0″
- Go to services and look for “MongoDB 3.0”, click start
- name – analytics,tracking.live, tracking.history and tracking.contact.
- mongodb prefix
- servername- in case of local, it’s default to localhost
- Mongo database(collection name)
This is for replicate set
This is how contact looks in Mongo, and some out of the box properties.
Hope this helps to give you base level understanding about MongoDB in Sitecore, and how to install MongoDB as windows service.
In the next post, we will see how we can scale MongoDB in Sitecore, and also closer look of contacts,collection and some queries to get data out of it.
Let me know your comments and feedback on the same, and anything which want to me cover specifically.
Happy learning 🙂