SharpCoder
SharpCoder

Reputation: 19183

Error while installing MongoDB as windows service

I tried installing MongoDB 3. X version as windows service. I executed following commands:

mkdir c:\data\db
mkdir c:\data\log
echo logpath=c:\data\log\mongod.log> "C:\mongodb\mongod.cfg"
echo dbpath=c:\data\db>> "C:\mongodb\mongod.cfg"
sc.exe create MongoDB binPath= "\"C:\mongodb\bin\mongod.exe\" --service --config=\"C:\mongodb\mongod.cfg\"" DisplayName= "MongoDB" start= "auto"

after executing these commands I got following message:

[SC] CreateService SUCCESS

But I was unable to start the windows service. Everytime, I tried installing MongoDB as windows service, it threw some error.

Then I followed this post: but I am still getting errors.

Please see below image for more information. enter image description here

Event log under System is showing following error: The MongoDB service terminated with service-specific error Cannot create another system semaphore..

Earlier I had installed MongoDB v 2.6 & I was able to install it successfully as windows service. I wonder if I need a different approach to install version 3.X.

Upvotes: 0

Views: 3355

Answers (2)

Sky
Sky

Reputation: 7711

I resolved this by removing mongod.lock and storage.bson files under /data/db.

Upvotes: 0

SharpCoder
SharpCoder

Reputation: 19183

I have now installed mongodb 2.6. and followed these instructions.

I suggest extracting the Mongo installation to c:\mongodb.

Create the c:\mongodb\logs and the c:\mongodb\data\db directories.

Then browse the the c:\mongodb\bin directory and run the following to remove the service (if you've installed it!):

mongod --remove

Then install the service, specifying the log and data directories:

mongod --logpath c:\mongodb\logs\mongo.log --dbpath c:\mongodb\data\db --directoryperdb --install

Upvotes: 1

Related Questions