[SERVER-13515] Cannot install MongoDB as a service on Windows Created: 08/Apr/14  Updated: 11/Jul/16  Resolved: 09/Apr/14

Status: Closed
Project: Core Server
Component/s: Admin, Usability
Affects Version/s: 2.6.0
Fix Version/s: 2.6.1, 2.7.0

Type: Bug Priority: Critical - P2
Reporter: Chris Becker Assignee: Shaun Verch
Resolution: Done Votes: 2
Labels: installation, service, windows
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-13590 Windows service is not installed anym... Closed
is duplicated by SERVER-13652 Windows 7 can not run the mongodb ser... Closed
Related
related to SERVER-13708 Windows service install fails unless ... Closed
related to DOCS-3119 Can't install MongoDB(2.6) as a servi... Closed
is related to DOCS-3182 Add note on Windows --install issue (... Closed
is related to SERVER-14263 Installer should install MongoDB as a... Closed
Operating System: ALL
Backport Completed:
Steps To Reproduce:

Install MongoDB 2.6 to c:\mongodb

create c:\mongodb\bin\data\db
create c:\mongodb\bin\logs

create mongod.cfg file with logpath and dbpath specified:

dbpath=c:\mongodb\bin\data\db
logpath=c:\mongodb\bin\logs\mongo.log

open cmd prompt as admin

cd \mongodb

run:
mongod --config C:\mongodb\bin\mongod.cfg --install

Participants:

 Description   
Issue Status as of May 07, 2014

ISSUE SUMMARY
The server options were canonicalized for 2.6 (SERVER-13379) to ensure compatibility between config file and parsed command line options. An oversight in the Windows service code regarding this change made it impossible to use the --install option to install MongoDB as a service on Windows.

USER IMPACT
Users upgrading to 2.6.0 were unable to install MongoDB as a service automatically and have to revert to a more complex manual process.

WORKAROUNDS
The service can be installed manually. The details of this workaround are described in this comment and on our documentation page Install MongoDB on Windows.

RESOLUTION
The changes from SERVER-13379 impact the Windows service code and have to be applied there as well.

AFFECTED VERSIONS
Version 2.6.0 is affected by this bug.

PATCHES
The patch is included in the 2.6.1 production release.

Original description.

Using the MongoDB 2.6 standard installer:

The instructions on the website say that this command should work:

mongod --config C:\mongodb\bin\mongod.cfg --install

mongod.cfg has dbpath and logpath set in it.

But that writes this to the mongo.log file:

2014-04-08T12:57:51.296-0700 --install has to be used with --logpath

So I tried this:

mongod --config C:\mongodb\bin\mongod.cfg --logpath C:\mongodb\bin\logs\mongo.log --install

I still get the same log message about needing --logpath



 Comments   
Comment by Derek Basch [ 18/May/14 ]

@Sun Lifeng

I fixed this error with the technique shown here:

SERVER-13982

Comment by Sun Lifeng [ 01/May/14 ]

I use the instruction above ,still got some error like this :

2014-05-01T13:24:00.631+0800 SEVERE: Failed global initialization: FileNotOpen F
ailed to open ""D:\mongodb\log\mongo.log""

Comment by Stennie Steneker (Inactive) [ 10/Apr/14 ]

Workaround to install as a service

You can manually install 2.6.0 as a service on Windows from an Administrator cmd prompt.

Assuming you have installed MongoDB using the MSI installer, the default path will be C:\Program Files\MongoDB 2.6 Standard. If you have installed in an alternative directory you will need to adjust the paths as appropriate.

Steps to install:

1) Open an Administrator command prompt

  • Windows 7 / Vista / Server 2008 (and R2)
    • Press Win + R, then type "cmd", then press Ctrl + Shift + Enter.
  • Windows 8 / 8.1
    • Press Win + X, then press A.

2. Make directories for your database and log files

mkdir c:\data\db
mkdir c:\data\log

3. Create a configuration file. This file can include any of the configuration options for mongod, but at a minimum must include a valid setting for logpath:

echo logpath=c:\data\log\mongod.log> "C:\Program Files\MongoDB 2.6 Standard\mongod.cfg"
echo dbpath=c:\data\db>> "C:\Program Files\MongoDB 2.6 Standard\mongod.cfg"

4. Create the MongoDB service

sc.exe create MongoDB binPath= "\"C:\Program Files\MongoDB 2.6 Standard\bin\mongod.exe\" --service --config=\"C:\Program Files\MongoDB 2.6 Standard\mongod.cfg\"" DisplayName= "MongoDB 2.6 Standard" start= "auto"

Note that sc.exe requires a space between "=" and the configuration values (eg "binPath= "), and a "\" to escape double quotes.

If this works you should see:

[SC] CreateService SUCCESS

5. Start the MongoDB service:

net start MongoDB

If successful you should be able to connect using the mongo shell. If the service did not start successfully, the log file should contain information to help you troubleshoot.

Comment by Githook User [ 09/Apr/14 ]

Author:

{u'name': u'Shaun Verch', u'email': u'shaun.verch@mongodb.com'}

Message: SERVER-13515 Check canonicalized version of logpath in Windows service startup

(cherry picked from commit b5c283687ce6c4a753f6c4ddfc5b79c464b23c75)
Branch: v2.6
https://github.com/mongodb/mongo/commit/2af46bcef99628210d00a24edc5bfa37966cd9a4

Comment by Githook User [ 09/Apr/14 ]

Author:

{u'name': u'Shaun Verch', u'email': u'shaun.verch@mongodb.com'}

Message: SERVER-13515 Check canonicalized version of logpath in Windows service startup
Branch: master
https://github.com/mongodb/mongo/commit/b5c283687ce6c4a753f6c4ddfc5b79c464b23c75

Comment by Shaun Verch [ 09/Apr/14 ]

Until this is fixed, there is a workaround that involves using an older binary:

  • Install a previous version of MongoDB (eg. 2.4.9) as a service
  • Upgrade to 2.6.0 by stopping the service, replacing the previous binaries with 2.6.0 ones, and starting the service again
Comment by Blake Niemyjski [ 09/Apr/14 ]

I'm also seeing this issue.

Comment by Shaun Verch [ 08/Apr/14 ]

The internal representation of the options was changed as part of SERVER-13379, but this check was not updated. Unfortunately, there is no workaround for this issue.

Generated at Thu Feb 08 03:31:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.