Configuring the Windows service for MongoDB

Source: Internet
Author: User
Tags create mongodb

[1] Creating Directorys and files

Create a configuration file and a directory path for MongoDB log Output ( logpath): First, you will manually create a new Windows service:  Create the address of the log file: MD "C:\Program Files\mongodb\log"  at the command prompt, create a configuration file for LogPath:
Echo LogPath =c:\program files\mongodb\log\ Mongo.log > "C:\Program files\mongodb\ mongod.cfg "--install
[2] running MongoDB service  Official information:  1. Configure directories and files. Create A configuration file and a directory path fo R MongoDB Log output (logpath):Create A specific directory for MongoDB log files:
MD "C:\Program Files\mongodb\log"
in the Command Prompt, create a configuration file for the logpath option for MongoDB:
echo Logpath=c:\program files\mongodb\log\mongo.log > "C:\Program files\mongodb\mongod.cfg"
2. Run the MongoDB service.Run All of the following commands in Command Prompt with "Administrative privileges:" Install the MongoDB service. For --install to succeed, you must specify the logpath run-time option.
"C:\Program files\mongodb\bin\mongod.exe"--config "C:\Program files\mongodb\mongod.cfg"--install
3. Stop or remove the MongoDB service as needed. 

To stop the MongoDB service with the following command:

net stop MongoDB

To remove the MongoDB service use the following command:

"C:\Program Files\mongodb\bin\mongod.exe"--remove
 "Official Information"manually Create a Windows Service for MongoDB

The following procedure assumes you has installed MongoDB using the MSI installer, with the default path C:\Program F ILES\MONGODB 2.6Standard.

If you have installed in a alternative directory, you'll need to adjust the paths as appropriate.

1Open an Administrator command prompt.Windows 7/vista/server (and R2)

Presses Win + R, then type cmd, then press Ctrl + Shift + Enter.

Windows 8

Press Win + X, then press A.

Execute the remaining steps from the Administrator command prompt.

2Create directories.

Create directories for your database and log files:

mkdir C:\data\dbmkdir C:\data\log
3Create a configuration file.

Create a configuration file. This file can include any of the configuration options for Mongod, butmust include a valid sett ing for logpath:

The following creates a configuration file, specifying both the LogPath and the dbpath settings in the C Onfiguration file:

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"
4Create the MongoDB service.

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"

Sc.exe requires a space between "=" and the configuration values (eg "binpath="), and a "" to escape double quot Es.

If successfully created, the following log message would display:

[SC] CreateService SUCCESS
5Start the MongoDB service.
net start MongoDB
6Stop or remove the MongoDB service as needed.

To stop the MongoDB service, use the following command:

net stop MongoDB

To remove the MongoDB service, first stop the service and then run the following command:

Sc.exe Delete MongoDB
                     

Configuring the Windows service for MongoDB

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.