MongoDB Close Method

Source: Internet
Author: User

Recently used MongoDB for development, on Linux, the habitual will use the kill-9 PID to shut down the service.

The result is that MongoDB always shuts itself down after each shutdown and then restarting MongoDB. Look at the log also did not see what comes, and then on Baidu Bai.

found that killing MongoDB with kill-9 is very serious.

Then went to the official website to stroll a circle, checked a bit

MongoDB uses a memory-mapped storage engine:

It will convert the disk IO operation into memory operation, if it is read operation, in-memory data play a role in the cache, if it is a write operation, memory can also convert random write operations into sequential write operations, in short, can greatly improve performance.

The write operation is flush to disk every 60 seconds (Syncdelay settings). If flush is stopped in this 60 seconds we are kill-9 then the write data from the last flush will be lost.

If you execute kill-9 while the flush operation is in progress, the file will become cluttered and may cause the data to be completely lost.

Official Description:

Sending a KILL signal kill-9 would probably cause damage as Mongod would not be able to cleanly exit. (In such a scenario, run the RepairDatabase command.)

Fortunately I found the early ah ... Otherwise, there's an accident.

Finally, you can close MongoDB in the following ways


1. Use Killall Mongod

2. Using Kil-15 PID

3. Execute the db.shutdownserver () command under Admin user


MongoDB Close Method

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.