On the use of MONGO

Source: Internet
Author: User
Tags mongodb server

The compiled binary version that is downloaded using the MongoDB website, if need to compile requires github download


1. Set the MongoDB program directory to $mongo, base file Settings

mkdir $MONGO/log

mkdir $MONGO/conf/

mkdir-p/data/db/

Touch $MONGO/conf/mongod.conf

2. Modify the configuration file $mongo/conf/mongod.conf

VI $MONGO/conf/mongod.conf

port = 27017 #端口. Default 27017,MONGODB default service TCP port, listening for client connections. If the port setting is less than 1024, such as 1021, you need root permission to start, can not be started with the MongoDB account, (ordinary account even 27017 will not do) otherwise error: [MONGO--port=1021 connection]

logpath = $MONGO/log/mongod.log #日志目录 for easy tracking.

dbpath =/data/db #mongo数据存放目录

fork = True #是否后台运行, set to True. Default is False

3. Start Mongod

mongod-f $MONGO/conf/mongod.conf

4. Watcher Output

If the output is as follows, the Mongod starts successfully

all output going to: $MONGO/log/mongod.log

Child process started successfully, parent exiting

5. Safely stop the Mongod process

The most basic method is to send SIGINT or sigterm signals to the MongoDB server.

If the front-end process runs on the terminal, the direct ctrl-c abort, otherwise, use kill to send the signal to abort.

Kill-2 Mongodpid (SIGINT)

Kill Mongodpid (SIGTERM)

Mongod receive SIGINT or SIGTERM, will safely exit, that is, such as the current operation or file pre-allocation is complete, close all open connections, the cache data flushed to disk, and finally stopped.

WARNING: Never send Sigkill (kill-9) to a running MongoDB. Causes the database to be shut down directly, causing the data file to be corrupted.

On the use of MONGO

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.