Setting up MongoDB in production
Posted 08/25/2016 by sanjeev gupta
In a previous blog I talked about setting up Mongo DB on development machine but if we have to configure mongodb on a production server then we need to do a bit more more.
We follow nearly the same steps a few more configuration settings are needed.
The following resources are required for a functional MongoDB setup:
- Create a local Sitecore 8.1 Instance.
- Verify Sitecore connection strings.
<?xml version="1.0" encoding="utf-8"?>
Sitecore connection strings.
All database connections for Sitecore are configured here.
<add name="analytics" connectionString="mongodb://localhost/analytics" />
<add name="tracking.live" connectionString="mongodb://localhost/tracking_live" />
<add name="tracking.history" connectionString="mongodb://localhost/tracking_history" />
- Download MongoDB from https://www.mongodb.com/download-center
Here's a step-by-step guide to getting the MongoDB to work once you have all of the resources.
Standard setup instructions
- Ensure you have installed and configured your Sitecore Instance.
- Install MongoDB using the Custom installation so you can change the default location. Typically, I put all my projects and websites on a separate non-operating system drive such as a D: drive. I will prefer to install mongo to D:/MongoDB/. Before you start the custom installation please complete Step 3/4 & 5.
- In the folder “MongoDB” create a folder called “data” and inside that folder, create a folder called “db”. Inside “data” folder, create another folder “log”. These will not be created for you during install so you will need to create them before MongoDB installation.
- In the folder “MongoDB” create another folder called “config” and inside config folder, create a new .cfg file and name it “mongod.cfg”. This is where we will store the configurations for MongoDB.
- Copy/paste following the configuration into the new “mongod.cfg” file and modify to your specific workstation:
bindIp: 127.0.0.1, privateIp address
- Now, install MongoDB as a Windows Service, so it will start every time you start up Windows and stay running. Open up a Command Prompt (Run As Administrator) and type in the following (modify if needed for your file paths):
D:\mongodb\bin\mongod.exe --dbpath "c:\mongodb\data\db"
sc.exe create MongoDB binPath= "D:\mongodb\bin\mongod.exe --service --config=\"D:\mongodb\config\mongod.cfg\"" DisplayName= "MongoDB" start= "auto"
- This will create a new windows service called MongoDB. Now, to start the service simply type in the following: net start MongoDB