MongoDB setting the way to run the background _mongodb

Source: Internet
Author: User
Tags mongodb

By default, shutting down Shell,mongodb stops running.

If you want to run in the background, you can start by simply adding the--fork function.

You can add--logappend after the log path to prevent the log from being deleted.

Copy Code code as follows:

Bin/mongodb--fork--dbpath=//--logpath=//--logappend

Run in the background, if you want to close it, you need to send him shutdownserver ()

1. General Order:

Copy Code code as follows:

$./mongod
> Use admin
> Db.shutdownserver ()

Note that this command is only allowed locally, or a certified client.

2, if this is a master-slave replication cluster, in the 1.9.1 version will be followed by the following steps to close
Check data update time from MongoDB
If all the time difference between the MongoDB and the master is over 10, then the MongoDB is not closed (in which case we can configure Timeoutsecs to get the data updated from MongoDB).
If one of them has a time difference from the MongoDB to the main service in 10 seconds, the primary server shuts down and waits for the update to complete from the MongoDB and close.
3. If there is no up-to-date from MongoDB and you want to force off the service, you can add force:true by adding the following command:

Copy Code code as follows:
> Db.admincommand ({shutdown:1, force:true})
>//or
> Db.shutdownserver ({force:true})

4, specify a specific timeout time of the shutdown server, command ibid, plus a timeoutsec: parameter
Copy Code code as follows:
> Db.admincommand (shutdown:1, Force:true, Timeoutsec:5)
>//or
> Db.shutdownserver ({force:true, timeoutsec:5})

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.