Tuesday, June 29, 2010

Installing MongoDB Service on Windows7

The time when SQL was considered to be the Lingua Francia for data storage and retrieval will soon be coming to an end. No SQL databases have shown that they are way faster when it comes to data storage and retrieval. Among the many new Object or Document Databases (for simplicity we will refer to them as No SQL Databases) MongoDB is one which has shown and is still showing a lot of promise. In order to make it easier for people to you can find a comparison fo SQL Server 2008 vs. MongoDB here.

Now lets have a look at how to install MongoDB as a service on Windows7, (below are actual extracts from http://www.michaelckennedy.net/blog/2010/04/29/MongoDBVsSQLServer2008PerformanceShowdown.aspx)

  • Download and extract the MongoDB archive appropriate for your system. http://www.mongodb.org/display/DOCS/Downloads
  • Copy the extracted folder to C:\ and rename it mongo.
  • Create a directory called 'data' inside C:\mongo
  • Click on the Start Menu and enter "cmd" in the search box. Right-click on cmd.exe and select "Run as administrator." This is VERY important because you won't be able to register MongoDB as a service if you run cmd.exe with normal privileges.
  • Type "C:\mongo\bin\mongod --install" to register MongoDB as a Windows service. This will probably output what may look like an error message, but don't worry ... as long as you really did run cmd.exe with administrator privileges, everything is fine.
  • Click on the start menu and enter "regedit" in the search box. Click on regedit.exe, and then browse to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services. There should be child folder there named MongoDB that has several keys inside it. If not, go back to step 4 and try again.
  • The ImagePath key should read "c:\mongo\bin\mongod --service" right now; change it to "c:\mongo\bin\mongod --service --dbpath c:\mongo\data". This will allow MongoDB to find its data files.
  • Click on the Start Menu and enter "services" in the search box. Click on the "Component Services" option.
  • In the pane on the far left, double-click on "Services (Local)." Locate MongoDB in the list in the center pane, and double click on it to bring up the properties inspector window.
  • Make sure "Startup type" is set to automatic. Then click on the "Start" button.
  • Browse to http://localhost:28017/ to verify that MongoDB is really running.
The purpose sharing the actual extracts from the above mentioned article was to increase the availability and have more and more people switch to MongoDB and to keep it for my own reference as well.