MongoDB Log Cleanup

Source: Internet
Author: User

MongoDB log relative to other databases should be a very large, just because of the alarm, so I look at a bit, there is a 15G log generation, the following is my cleanup process


For security reasons, our server prohibits the use of RM commands, so I created a Mongolog folder in the/home directory

Check the log size and number first

#ls/opt/mongodb/log

Total 15G
-rw-r--r--. 1 root root 6.6G Jul 2 17:10 mongodb.log
-rw-r--r--. 1 root root 6.5K Oct mongodb.log.2013-10-16t13-13-26
-rw-r--r--. 1 root root 1.6K Oct mongodb.log.2013-10-23t10-10-45
-rw-r--r--. 1 root root 112M Jan 17:10 mongodb.log.2014-01-16t11-08-59
-rw-r--r--. 1 root root 8.0G Apr 8 23:53 mongodb.log.2014-04-09t01-17-33

#mkdir/home/mongolog

Then look at the process number of MongoDB

#ps-ef | grep MONGO


[Email protected] log]# Ps-ef | grep MONGO
Root 9033 7254 0 17:17 pts/0 00:00:00 grep MONGO
Root 10771 1 9 Apr09? 7-23:16:33 bin/mongod-f etc/mongo.conf


The process number found is 10771.

The following signal to the process, let the program to regenerate the log, which does not affect the service situation of MongoDB

KILL-SIGUSR1 10771

Check the size and number of logs again.

#ls/opt/mongodb/log

Total 15G
-rw-r--r--. 1 root root 0 Jul 2 17:11 mongodb.log
-rw-r--r--. 1 root root 6.5K Oct mongodb.log.2013-10-16t13-13-26
-rw-r--r--. 1 root root 1.6K Oct mongodb.log.2013-10-23t10-10-45
-rw-r--r--. 1 root root 112M Jan 17:10 mongodb.log.2014-01-16t11-08-59
-rw-r--r--. 1 root root 8.0G Apr 8 23:53 mongodb.log.2014-04-09t01-17-33
-rw-r--r--. 1 root root 6.6G Jul 2 17:11 mongodb.log.2014-07-02t09-11-18
Isn't it more than a log

Then move the log to the directory you just created.

#mv mongodb.log.201*/home/mongolog/

This article is from the "Jeff" blog, so be sure to keep this source http://zhangxz.blog.51cto.com/5490116/1433638

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.