MongoDB as a Windows service startup

Source: Internet
Author: User
Tags mongodb server

MongoDB as a Windows service startup

  1. Windows version Installation
    • MongoDB Official Download Station is http://www.mongodb.org/downloads, can go up to download the latest corresponding version, there are 32-bit, 64-bit.

    • Set the Mogodb directory.
      Unzip the downloaded compressed package to the specified directory. After I unzip, copy the content to, D:\MongoDB
    • Set the data file path
      Create a new Data folder under D:\MongoDB and a DB folder under the Data folder
    • Set the MongoDB log storage path
      Create the logs folder below D:\MongoDB and create the MongoDB.log file
  2. Configuring the MongoDB Server
    1. Open the cmd window and go to the Mongodb\bin directory and enter the command:
      1. Do not set port number, default is 27017 port number
        Mongod.exe--logpath D:\MongoDB\logs\MongoDB.log--logappend--dbpath D:\MongoDB\data--directoryperdb--service '
      2. Set a custom port number
        Mongod.exe--port 20161--logpath D:\MongoDB\logs\MongoDB.log--logappend--dbpath D:\MongoDB\data--directoryperdb-- Service

    2. After the service is created, the default is stop state, we need to manually open the service, with the command, net start MongoDB, open the service.
      After the service is turned on, the data folder that was created automatically generates several files, which should be related to the file.
  3. Client Connection Validation
    1. After the service is turned on, there are two ways to verify that the success is actually turned on
    2. Using the command line, MONGO 127.0.0.1:27017 to show that the connection was successful. Connecting To:127.0.0.1:27017/test
    3. Another way is to enter in the browser: http://localhost:27017/, the page displays such a line of words:

      It looks like you is trying to access MongoDB over HTTP on the native driver port.

      This can also detect whether the server can be connected, but the ego feels a little bit.

    4. At this point, our MONGO service is created and can be used normally. Each time you use, enter the name, net start MongoDB to open the service.
  4. View Logs
    • The MongoDB.log under the D:\MongoDB\logs
    • Records of operations related to Mogodb are recorded here.
  5. Add
    1. The service is created, can be started, stopped, deleted, and the corresponding command line is:
      net start MongoDB start-up service
      net stop MongoDB stop service
      SC Delete MongoDB Delete Service (this command is suitable for most services, only need to change the service name later)

MongoDB as a Windows service startup

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.