Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mongodb Log cleanup

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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/

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report