Install Mongo On Windows As a Service

Mongo is a common NoSql database that is flexible and easy to use.  It’s ability to scale and shard across many nodes makes it a great option for load balancing and scaling an application domain that fits a NoSql type schema.

1.  Download the latest version of Mongo that fits your platform (i.e. x86, x64).  Run the installer and place the application files in C:\Tools\MongoDB…  Follow my environment variable setup post for certain development folders.

2. Create an environment variable MONGO_HOME to point to the root of the mongo application directory.  If you followed my post on environment variable setup this would be %TOOLS_HOME%\MongoDB…  Add %MONGO_HOME%\bin to the Path environment variable.

3.  Create a directory to store the mongo data.  The simple approach is to create the directory C:\data\db.  This is Mongo’s default but can be changed using it’s configuration file.

4.  Create a log directory for the Mongo logs.  The simplest is to create “log” directory under the root Mongo directory C:\Tools\Mongo….

5.  Create a mongodb.conf file in C:\Tools\MongoDB… root directory.  This put the following minimum information in the file.

systemLog:
   destination: file
   path: "/Tools/MongoDB 2.6 Standard/log/mongodb.log"
net:
   bindIp: 127.0.0.1
   port: 27017
storage:
   journal:
      enabled: true
   dbPath: "/data/db"

 

6.  Open a command window (ensure it’s in Administrator mode) enter the following command.  This will work if your Path variable is set correctly.

mongodb.exe --config "C:\Tools\MongoDB 2.6 Standard\mongodb.conf" --install

No comments: