Andreas
Andreas

Reputation: 5335

Running mongod as a windows service

i have installed mongodb on win32 and i am trying to run it as a service.

I have followed the instructions posted here: http://www.deltasdevelopers.com/post/Running-MongoDB-as-a-Windows-Service.aspx

but when when windows tries to 'load'/'run' the service there is a problem. I see the service under the services control banner constantly in the 'starting' state.

The result: the service is not started and windows is constantly trying to start it without success.

The instructions i have followed are:

At the command line

C:\mongodb\mongod -install then C:\mongodb\mongod -service

Then i modified the Win Registry Entry for the MongoDB Service by setting the ImagePath key to the value of C:\mongodb\mongodb.exe -service

Any advice? What am i doing wrong?

Upvotes: 2

Views: 5118

Answers (5)

Umeshwaran
Umeshwaran

Reputation: 11

I have been faced similar issue. And i tried above solutions still have not get any result.

finally below code is solved my issue.

-> Command prompt open as administrator.

-> Copy and paste the below code after changing the proper bin and config path.

sc.exe create MongoDB binPath= "\"d:\MongoDB\bin\mongod.exe\" --service --config=\"d:\MongoDB\mongo.cfg\"" DisplayName= "MongoDB" start= "auto"

Happy Coding !!!!!!

Upvotes: 1

armyofda12mnkeys
armyofda12mnkeys

Reputation: 3442

I'd do it this way just cause I like to customize/organize things better: Unzip mongo to where you want.

I like putting all the configuration in a file (my preference, since I didnt like default location of C:/data/db, and didn't like all the options as commandline params)... Looks something like: [C:\dev\mongodb\data\mongodb.conf]

dbpath = C:\dev\mongodb\data\db
logpath = C:\dev\mongodb\data\mongodb.log.txt
logappend = false

Then I put C:\dev\mongodb\bin in my Env Variable's PATH (so can call mongo.exe from any dir), but not needed...

Then on command line to install the Windows Service:

$ cd C:\dev\mongodb\bin
$ mongod.exe -f C:\dev\mongodb\data\mongodb.conf --install

It will create a Windows Service which if you want, can start manually via:

$ net start MongoDB

//Use qoutes if changed service name (via -serviceName to mongod --install), like: net start "Mongo DB"

Upvotes: 2

Wilfred Knievel
Wilfred Knievel

Reputation: 3245

Just for future reference: running mongo as a windows service

Also lots of people seem to be saying: specify the whole path to the mongod.exe:

c:\mongo\mongod.exe --logpath "c:\mongo\logs\mongo.log" --logappend --dbpath "c:\mongo\data" --directoryperdb --install

Also if you're running Windows 7 don't forget to run the command window as an administrator.

Upvotes: 4

Rakesh Waghela
Rakesh Waghela

Reputation: 21

Specifying several parameters at once is a good choice. mongod --install to install as a service

--rest to enable rest access to mongodb

–master to set up mongodb instance as master.

–logpath this is mandatory when you install mongodb as service

--dbpath this too is mandatory for mongodb to run.

Here is a step by step guide describing the installation of MongoDB Service on Windows 7.

Upvotes: 1

sym3tri
sym3tri

Reputation: 3823

Regardless of whether you're running as a service or not, you need to specify the --dbpath argument to mongod.exe.

Also, you shouldn't have to edit the registry. You can just issue the command like this:

C:\mongodb\mongod.exe --dbpath C:\data\db --install

Upvotes: 0

Related Questions