MongoDB log too big what to do?

Source: Internet
Author: User

MongoDB's log growth is fast,/Var space is immediately full, even if you change to another disk partition to save the log, the log is growing fast, the disk to see the chime.

A good way to do this is to use a rotational log.

MongoDB rotation Log a bit strange, the Linux mongd service accepts a KILL-SGIUSR1 command immediately renames the current log file to a file with a date, and then creates a new log file.

You can configure a rotation policy if you do not want a general rotation log. However, after testing, sending the command will not affect MongoDB's service.

Here is an example of finding the process ID and then sending the command.

[Email protected]:/etc/init.d# ps-def | grep mongodmongodb    723     1 May04?        6-22:23:53/usr/bin/mongod--config/etc/mongodb.confroot     22035 22012  0 20:22 pts/2    00:00:00 grep--color= Auto Mongod[email protected]:/etc/init.d# kill-sigusr1 723[email protected]:/etc/init.d# cd/home/mongodb/log/[email protected]:/home/mongodb/log# lsmongodb.log  Mongodb.log.2014-05-18t12-23-51[email protected]:/home/mongodb/ log# ls-alhtotal 20Gdrwxrwxrwx 2 root    root    4.0K may 20:23. drwxrwxrwx 4 root    root    4.0K Apr 20 21:25. .-rw-r--r--1 MongoDB nogroup  34K 20:24 mongodb.log-rwxrwxrwx 1 mongodb nogroup 20G may  20:23 MongoDB. Log.2014-05-18t12-23-51

Official documents:

http://docs.mongodb.org/manual/tutorial/rotate-log-files/


You can now move or delete the log files for the previous 20G.

You can also make a regular script on your own and send commands to the Mongod service regularly.


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.