abbett.org

i.e. Jonathan Abbett — web crafter, healthcare designer, amateur kosher cheesemaker.

Installing MongoDB as a Windows service

5 August 2012
Filling in the missing instructions.

There are some missing details in the MongoDB Windows installation instructions.

Specifically:

  1. The logpath configuration needs to point to a log file, not a log directory.
  2. You need to create your log and database directories manually.
  3. If you make any mistakes in your configuration, the services goes haywire due to its default automatic restart setting.

So, I thought I'd write up a very abbreviated summary of how I got it running as a service on my Windows 7 machine.

  1. Download the MongoDB Windows distribution.
  2. Extract the contents of the download and rename the folder. I extracted mine to c:\ and renamed the directory to c:\mongodb
  3. Create a database directory. I created mine at c:\mongodb\data\db
  4. Create a log directory. I created mine at c:\mongodb\log
  5. Create a configuration file. Here's the contents of mine, at c:\mongodb\mongod.cfg:

    logpath=C:\mongodb\log\mongodb.log
    logappend=true
    dbpath=C:\mongodb\data\db
    
  6. Open a command prompt with administrator privileges.

  7. Install the MongoDB service, referring to the location of the configuration file your created in step 5:

    C:\mongodb\bin\mongod.exe --config C:\mongodb\mongod.cfg --install
    
  8. Start the MongoDB service:

    net start MongoDB
    

As I mentioned eariler, if you have a misconfiguration (as I did the first time I installed it), the MongoDB service will restart, and restart, and restart, generating a giant log file all the while. To prevent this, launch the Services admin tool, open the MongoDB service properties, click the "Recovery" tab, and change First/Second/Subsequent Failures to "Take No Action."

If your service is in a restart loop, just try running "net stop MongoDB" over and over until it works.

comments powered by Disqus
Uncaught Exception

Uncaught Exception

Array and string offset access syntax with curly braces is deprecated

Origin

anchor/libraries/markdown.php on line 1396

Trace

#0 [internal function]: System\Error::shutdown()
#1 {main}