2. Getting started with MongoDB-running as a Windows Service

Source: Internet
Author: User
Tags install mongodb

Address: http://www.mongodb.org/display/DOCS/Windows+Service

 

On Windows, cmdd.exe supports local installation and operation of Windows Services.

Service commands

Service-related Commands include:

JS Code
  1. Mongod -- install
  2. Mongod -- service
  3. Mongod -- remove
  4. Mongod -- reinstall

 

You can also pass the following options to-install and-reinstall.

JS Code
  1. -- Servicename {Arg}
  2. -- Serviceuser {Arg}
  3. -- Servicepassword {Arg}

 

The-install and-Remove options install Mongo as services and remove Mongo. The -- service option is used to enable the Service. -- Reinstall will try to remove the service and then install it. If the service has not been installed, -- reinstall is also valid.

If the service is running, -- remove and-reinstall both stop it.

To change the service name, use-servicename. -Serviceuser and-servicepassword are used no matter whether Mongo is run as a local, domain, or local SYSTEM account.

With the command line passed along with -installto any node of mongod.exe, the service will be used to configure the running of mongod.exe. See the following example (these parameters are not required to run mongod as a Service ):

JS Code
  1. Mongod -- logpath D: \ Mongo \ logs -- logappend -- dbpath D: \ Mongo \ data -- directoryperdb -- install

 

 

This causes a service called Mongo to run the following command:

Mongo code
  1. Mongod -- logpath D: \ Mongo \ logs -- logappend -- dbpath D: \ Mongo \ data -- directoryperdb

 

 

Installed on win7

To install the service on win7, you must ensure that you are running as an administrator. To do this, open the menu and click "cmd.exe" in the search box ". Right-click the command line program that appears and select "Run as administrator ".

In this case, you can install MongoDB as a service through-install as described above.

 

Use mongos as a Windows Service

Currently (the minimum version is 1.8), mongos does not support direct installation for Windows Services. However, by using Windows Resource Kit (Click here to download), you can configure to enable mongos when the Windows Host starts.

1. Assume that your mongos configuration file is c: \ MongoDB \ mongos. conf, And you have tested it.

2. Run cmd.exe with the administrator ID.

3. Install srvany.exe as a service, as shown in the following figure:

C: \ Program Files \ Windows resource kits \ tools> "C: \ Program Files \ Windows Resource

CMD code
  1. Kits \ tools \ instsrv.exe "mongos" C: \ Program Files \ Windows resource kits \ tools \ srvany.exe"

 
The output is similar to this:

 

CMD code
  1. The service was successfuly added \!
  2. Make sure that you go into the control panel and use
  3. The Services applet to change the account name and
  4. Password that this newly installed Service will use
  5. For its security context.

10.open regedit.exe.

 

11. Find the subkey

HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ mongos

12. Right-click mongos, select new> item, and enter parameters.

13. Select parameters.

14. Right-click the window on the right, select new> string value, and enter application.

15. Change the applicationvalue to the full path of cmds.exe, for example, C: \ MongoDB \ bin \ cmds.exe.

16. Right-click again, choose new> string value, and enter appparameters.

17. Modify the value to mongos parameters, for example, -- config c: \ MongoDB \ mongos. conf.

18. Use Net start mongos to check whether the service can be enabled.

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.