0

I have the issue with running MongoDB 3.0 service in Windows 7. I have created the data/db and data/log inside MongoDB root and configured mongod.conf file:

Edited

# mongod.conf

# for documentation of all options, see:
#    http://docs.mongodb.org/manual/reference/configuration-options/

# where to write logging data.
systemLog:
    destination: file
    logAppend: true
    path: C:\Program Files\MongoDB\data\log\mongod.log

# Where and how to store data.
storage:
    dbPath: C:\Program Files\MongoDB\data\db
    journal: 
        enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# how the process runs
processManagement:
    fork: true
    pidFilePath: C:\Program Files\MongoDB\mongod.pid

# network interfaces
# net:
#  port: 27017
#  bindIp: 127.0.0.1  # Listen to local interface only, comment to listen on all interfaces.


#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options

#auditLog:

#snmp:

Then I have created a windows service which will run the mongodb on startup:

sc.exe create MongoDB binPath= "C:\MongoDB\bin\mongod.exe
 --service --config=C:\MongoDB\mongod.conf" displayname= "MongoDB 3.0 Standard"
start= "auto"

I have tried also:

sc.exe create MongoDB binPath= "\"C:\MongoDB\bin\mongod.exe\" --service --config=\"C:\MongoDB\mongod.conf\"" DisplayName= "MongoDB" start= "auto"

MongoDB service properties show me path to executable:

C:\MongoDB\bin\mongod.exe --service --config=C:\MongoDB\mongod.conf

Attempts to run service(net start MongoDB) show me error message:

The service is not responding to the control function.
More help is available by typing NET HELPMSG 2186.

I know this issue is quite popular but most of solutions led to wrong paths, file names/extensions which don't solve my problem.

UPDATE:

Suggestion to create windows service under specified user doesn't help me as well (the same message during service start):

C:\Users\Administrator>sc.exe create MongoDB binPath= "C:\MongoDB\bin\mongod.exe
 --service --config=C:\MongoDB\mongod.conf" displayname= "MongoDB 3.0 Standard"
start= "auto" obj= ".\Administrator" password= "@gdgsfg1"

Moreover, I have tried to specify username and password via services.msc -> MongoDB -> Properties->Log on

Windows Event log:

Error   6.05.2015 19:54:25  Service Control Manager 7009    None
A timeout was reached (30000 milliseconds) while waiting for the MongoDB service to connect.

Error   6.05.2015 19:54:25  Service Control Manager 7000    None
The MongoDB service failed to start due to the following error: 
The service did not respond to the start or control request in a timely fashion.
Viktor M.
  • 4,393
  • 9
  • 40
  • 71
  • I would start checking with access rights. Mind that when launched in a service it runs by default from a rather limited user. At first try changing it to an administrator (temporarily). To eliminate possibility of access denied. You file locations are rather pretentious: root of system drive – Kirill Slatin May 06 '15 at 10:01
  • I have logged in as Administrator, also I have run cmd as Administrator - still the same thing. As for the root of system drive is just temporary decision to avoid problems with path quoting e.g. "C:\Program Files\..." at this moment. – Viktor M. May 06 '15 at 10:10
  • I am not talking about your work as a UI user. On windows services are usually run from `Local System` account. If your service is properly registered you can find it in services Alt+X/Computer Managment/Services and Applications/Services – Kirill Slatin May 06 '15 at 10:13
  • Examine this [post](http://stackoverflow.com/questions/14408973/using-sc-exe-to-set-service-credentials-password-failing) for a way to create a service via console (`sc.exe`) and provide a non-default user to run from – Kirill Slatin May 06 '15 at 10:15
  • Unfortunately, it doesn't help me, see 'Update' in the post how I tried to do it. – Viktor M. May 06 '15 at 11:02
  • Did you run the hotfix to [resolve issue with memory mapped files](http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/)? – Kirill Slatin May 06 '15 at 11:22
  • Yes, hotfix installed and the machine rebooted. – Viktor M. May 06 '15 at 11:40
  • So far too little info to judge... What does Windows Application Log read about the failed service? There must be at least anything if service fails to start – Kirill Slatin May 06 '15 at 14:33
  • I have tried to install windows service by previous instructions from MongoDB 2.4: mongod.exe --config "C:\Program Files\MongoDB\mongod.conf" --install. And i figure out that YAML structure is wrong based on the following error message: Unrecognized option: processManagement.fork – Viktor M. May 06 '15 at 16:59
  • But I cannot recognize what is actually wrong with processManagement option. I have already check option spelling, spaces. HOWEVER, if I will comment processManagement with all its options, service will run successfully! – Viktor M. May 06 '15 at 17:05
  • so is your issue resolved? – Kirill Slatin May 07 '15 at 01:31
  • Issue is solved despite I didn't understand why processManagement.fork option not work. – Viktor M. May 07 '15 at 21:21
  • Be so kind as to post your solution as an answer – Kirill Slatin May 08 '15 at 04:14
  • Regarding fork not working http://stackoverflow.com/q/15185012/4573999 – Kirill Slatin May 08 '15 at 04:28
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/77271/discussion-between-kirill-slatin-and-user1376885). – Kirill Slatin May 08 '15 at 04:30

1 Answers1

2

I have found the solution why MongoDB service doesn't start successfully.

First of all, install windows mongodb service by this way to see all kind of errors with your YAML config file or anything else during service install(sc.exe doesn't provide enough ifnormation during mongodb service install):

mongod.exe --config "C:\Program Files\MongoDB\mongod.cfg" --install

Actually, my issue was with processManagement.fork option which is not exist in Windows since it causes error Unrecognized processManagement.fork option. So, I have remove this option from my config file and service starts fine.

The final config file:

systemLog:  
    destination: file  
    logAppend: true  
    path: C:\Program Files\MongoDB\data\log\mongod.log  
    timeStampFormat: iso8601-utc  

storage:  
    dbPath: C:\Program Files\MongoDB\data\db  
    journal:  
        enabled: true  

processManagement:
    pidFilePath: C:\Program Files\MongoDB\mongod.pid  

net:  
    port: 27017  
    bindIp: 127.0.0.1
Viktor M.
  • 4,393
  • 9
  • 40
  • 71