Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring MongoDB on Windows

I am trying to set up MongoDB on Windows, and the online docs seem far from accurate.

Under "Configure a Windows Service" part, step 1 mentions to create a config file. Then it mentions to fill in the file with a line in the format logpath="X:\path\mongo.log". However, following the link, the config file is said to be in YAML format, which renders the previous line unreadable in YAML.

I have created a basic mongodb.cfg(.cfg or .conf??) file:

systemLog:
   destination: file
   path: "P:\\Servers\\MongoDB\\logs\\mongodb.log"
   quiet: true
   logAppend: true
storage:
   dbPath: "P:\\Servers\\MongoDB\\data"
   journal:
      enabled: true
net:
   bindIp: 127.0.0.1
   port: 27017

However when I start mongod --config P:\Servers\MongoDB\mongodb.cfg, the service just won't give any output at all, and just hangs.

If I remove the dbPath line, it will just close itself with no message at all.

I have also tried to leave the mongodb.cfg file just like this:

logpath="P:\Servers\MongoDB\logs\mongodb.log"
dbpath="P:\Servers\MongoDB\data"

But execution aborts complaining about any of the 2 paths, even tho they exist. Tried with single backslashes and with escaped backslashes (\\) with no success.

The only way the service works and listens for connections is to manually pass --dbpath only, and ignore any config file and logpath at all. Obviously this is not serious, as I need to keep track of the logs and also might need to change config parameters at some later point.

This is nuts... Am I missing something very basic or this docs are a real mess?

like image 743
Jago Avatar asked Jul 16 '14 04:07

Jago


People also ask

Can you run MongoDB on Windows?

Installing and Running MongoDB on a Windows MachineDownload the MongoDB installer file from the downloads section of the MongoDB website. Find the dowloaded . msi file in the Windows Explorer. Double click the file and follow the prompts to install Mongo.


2 Answers

For those who installed via *.msi installer and wondering where is .conf file located. Run 'services.msc' and check properties of mongodb service runnable file.

like image 64
A. L. Avatar answered Sep 22 '22 14:09

A. L.


Here is my simple test MongoDB Config file for Windows. Note that I had to have 2 spaces before each property, e.g., path. When I had 3 spaces I got an error at startup.

I start the server with: mongod --config c:\tools\mongodb\db\mongod.cfg

systemLog:
  destination: file
  path: "C:\\tools\\mongodb\\db\\log\\mongo.log"
  logAppend: true
storage:
  dbPath: "C:\\tools\\mongodb\\db\\data"
security:
  authorization: enabled
like image 35
wbdarby Avatar answered Sep 20 '22 14:09

wbdarby