Core Server
  1. Core Server
  2. SERVER-13515

Cannot install MongoDB as a service on Windows

    Details

    • Operating System:
      ALL
    • # Replies:
      8
    • Last comment by Customer:
      true
    • Driver Changes:
      Not Needed
    • User Summary:
      Completed
    • Steps To Reproduce:
      Hide

      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

      Show
      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

      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

        Issue Links

          Activity

          Hide
          Shaun Verch (Inactive)
          added a comment -

          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.

          Show
          Shaun Verch (Inactive)
          added a comment - 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.
          Hide
          Blake Niemyjski
          added a comment -

          I'm also seeing this issue.

          Show
          Blake Niemyjski
          added a comment - I'm also seeing this issue.
          Hide
          Shaun Verch (Inactive)
          added a comment -

          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
          Show
          Shaun Verch (Inactive)
          added a comment - 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
          Hide
          Githook User
          added a comment -

          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

          Show
          Githook User
          added a comment - 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
          Hide
          Githook User
          added a comment -

          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

          Show
          Githook User
          added a comment - 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
          Hide
          Stephen Steneker
          added a comment - - edited

          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.

          Show
          Stephen Steneker
          added a comment - - edited 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.
          Hide
          Sun Lifeng
          added a comment -

          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""

          Show
          Sun Lifeng
          added a comment - 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""
          Hide
          Derek Basch
          added a comment -

          @Sun Lifeng

          I fixed this error with the technique shown here:

          SERVER-13982

          Show
          Derek Basch
          added a comment - @Sun Lifeng I fixed this error with the technique shown here: SERVER-13982

            People

            • Votes:
              2 Vote for this issue
              Watchers:
              21 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since reply:
                41 weeks, 3 days ago
                Date of 1st Reply: