MongoDB Windows installation Service methods and considerations _mongodb

Source: Internet
Author: User
Tags install mongodb mongodb mongodb windows win32

MongoDB Windows Installation Services

MongoDB, as a database based on distributed file storage, has been in hot pursuit for nearly two years. Flexible access to data and efficient processing make it widely used in Internet applications.

Recently I began to study the use of MongoDB under the Windows 32-bit platform, for convenience, I prefer to install it as Windows System services. This will not have to open a mongod every time the mainstream program.

However, the command to search on the internet sometimes does not allow the service to register successfully, there are several problems. Next I will write down the problems and solutions I have encountered.

First from the MongoDB official download the latest release version: Http://www.mongodb.org/downloads

At present, I am using the 2.0.2 version.

The installation is very simple, the decompression is OK. I put it under D, and here's the directory structure:

C:\Documents and Settings\chaijunkun>d: 
 
d:\>cd mongodb-win32-i386-2.0.2 
 
D:\mongodb-win32-i386-2.0.2 
 the volume in >cd bin D:\mongodb-win32-i386-2.0.2\bin>dir Drive D is not labeled. 
 the serial number of the volume is f4ca-b47c 
 
 D:\mongodb-win32-i386-2.0.2\bin directory 
 
2012-02-01 16:48  <DIR>     . 
2012-02-01 16:48  <DIR>. 
2011-12-14 12:23     3,644,928 bsondump.exe 
2011-12-14 12:25     1,793,536 mongo.exe 
2011-12-14 12:28     3,952,640 mongod.exe 
2011-12-14 12:30 3,660,800 mongodump.exe 2011-12-14 12:32     3,651,072 Mongoexport.exe 
2011-12-14 12:34     3,656,192 mongofiles.exe 2011-12-14 12:36     3,668,992 Mongoimport.exe 
2011-12-14 12:38     3,654,656 mongorestore.exe 2011-12-14 12:39     2,807,808 Mongos.exe 
2011-12-14 12:41     3,689,472 mongostat.exe 
2011-12-14 12:46     3,657,216 Mongotop.exe 
       11 files   37,837,312 bytes 
        2 directories 97,404,313,600 free bytes 

The next step is to install the MongoDB service, but at this point pay attention to two points:

1. Keep the current directory of the command line unchanged, that is, still remain in the D:\mongodb-win32-i386-2.0.2\bin directory. Using absolute positioning to manipulate this directory after any changes to another directory will cause the service installation to fail

Note: What does that mean? That means keeping the current state on the line. Suppose you reopen a cmd, the starting directory becomes a

 
 

When you use

C:\Documents and Settings\chaijunkun>d:\mongodb-win32-i386-2.0.2\bin\mongod.exe ....... 


Such a way to register the service will still fail to register.

2. Create a directory beforehand to save the database file. If you do not create this directory, the registration service will appear to have been registered successfully on the surface. However, starting the service will find that the Mongod.exe process will be repeatedly established, destroyed, established, destroyed. The service status also becomes started, stopped, started, stopped, and the client cannot connect to the database at all.

Here I use the Mongodbdata directory under C disk as the data file storage directory, so set up a directory:

 
 

Well, here's your job done, and you can install the service here:

D:\mongodb-win32-i386-2.0.2\bin>mongod--install--servicename mongodb--servicedisplayname mongodb--logpath c:\ MongoDB.Log--dbpath C:\MongoDB--directoryperdb 

Here is a brief description of the parameters used and their implications:

--install: Install MongoDB Service
--servicename: Service name to use when installing Windows service
--servicedisplayname: The name of the service displayed in Windows Service Manager, as follows:

--logpath:mongodb log output file name. Although this parameter literal translation is "log path", in fact, to specify a specific full file name. Here I am using the MongoDB.Log file in the C-packing directory. This file is not created in advance and is specified directly.
--dbpath: Specifies the path where the MongoDB data is stored. This is the most critical parameter, not only the directory to exist, and it is best not to end with "\".
--DIRECTORYPERDB: This parameter is very good to understand, let MongoDB according to the database, for each database to create a directory, so-called "directory per database"

Well, once the above command is executed, the service can be registered successfully. If you are using Windows Vista or Windows 7, you should pay special attention to its UAC mechanism, you must open cmd with administrator privileges, and then register the service to register successfully.
Open the Service Manager, start the MongoDB service, and discover that the service can be run stably. Congratulations, it's done!

Thank you for reading, I hope to help you, thank you for your support for this site!

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.