Mongodb Log cleanup
mongodb log relative to other databases should be considered very large, just because of the alarm, so I check it, there are 15G log generation, the following is my cleaning process
For security reasons, our server forbids the rm command, so I created a mongolog folder under/home
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 16 2013 mongodb.log.2013-10-16T13-13-26
-rw-r--r--. 1 root root 1.6K Oct 16 2013 mongodb.log.2013-10-23T10-10-45
-rw-r--r--. 1 root root 112M Jan 16 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 mongodb's progress number
#ps -ef | grep mongo
[root@db 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 detected is 10771.
The following signals the process to regenerate the log without affecting mongodb's service
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 16 2013 mongodb.log.2013-10-16T13-13-26
-rw-r--r--. 1 root root 1.6K Oct 16 2013 mongodb.log.2013-10-23T10-10-45
-rw-r--r--. 1 root root 112M Jan 16 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
Is it too much? A journal?
Then move the log to the directory you just created
#mv mongodb.log.201* /home/mongolog/