Configure a Windows Service for MongoDB

Steps

  1. On the machine on which you installed MongoDB Community Edition, select the Windows Start button, then navigate to and right-click Command Prompt, and then select Run as administrator.

    A command prompt window appears.

  2. On the command prompt window, enter the following:

    mkdir c:\data\db

    mkdir c:\data\log

    Two directories that will be used by APM System Monitoring are created.

  3. Create a configuration (.cfg) file. The file must set systemLog.path. Include additional configuration options as needed. For example, to create a file at C:\data\mongod.cfg that specifies both systemLog.path and storage.dbPath, the file would contain the following text:

    systemLog:

    destination: file

    path: c:\data\log\mongod.log

    storage:

    dbPath: c:\data\db

    Note: In the configuration file, each tab indentation seen in the preceding text should be replaced with two spaces.

  4. On the command prompt window, enter the following:

    "C:\Program Files\MongoDB\Server\3.2\bin\mongod.exe" --config "C:\data\mongod.cfg" --install

    Note: To use an alternate dbpath, specify the path in the configuration file (e.g., C:\data\mongod.cfg) or on the command line with the --dbpath option.

    The MongoDB service is installed.

  5. On the command prompt window, enter the following:

    net start MongoDB

    The MongoDB service is started, and the Windows service is configured.

What's Next?

Related Information

Copyright © 2018 General Electric Company. All rights reserved.