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

The solution to the excessive size of MongoDB logs

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

Share

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

The log of MongoDB is growing very fast, and the space of / var is immediately full. Even if you switch to another disk partition to save the log, the log will grow very fast, and the disk will soon run out.

A good way to do this is to use rotating logs.

MongoDB's rotation log is a bit strange. After accepting a kill-SGIUSR1 command, the mongd service under Linux renames the current log file to a dated file, and then creates a new log file.

Instead of a normal rotation log, you can configure a rotation strategy. However, it doesn't matter, after testing, sending this command will not affect the service of MongoDB.

Here is an example of looking up the process id and then sending the command.

Root@www.linuxidc.com:/etc/init.d# ps-def | grep mongod

Mongodb 723 1 48 May04? 6-22:23:53 / usr/bin/mongod-- config / etc/mongodb.conf

Root 22035 22012 0 20:22 pts/2 00:00:00 grep-color=auto mongod

Root@www.linuxidc.com:/etc/init.d# kill-SIGUSR1 723

Root@www.linuxidc.com:/etc/init.d# cd / home/mongodb/log/

Root@www.linuxidc.com:/home/mongodb/log# ls

Mongodb.log mongodb.log.2014-05-18T12-23-51

Root@www.linuxidc.com:/home/mongodb/log# ls-alh

Total 20G

Drwxrwxrwx 2 root root 4.0K May 18 20:23.

Drwxrwxrwx 4 root root 4.0K Apr 20 21:25..

-rw-r--r-- 1 mongodb nogroup 34K May 18 20:24 mongodb.log

-rwxrwxrwx 1 mongodb nogroup 20G May 18 20:23 mongodb.log.2014-05-18T12-23-51

Official documents:

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

Now you can remove or delete the log files of the previous 20g.

You can also send commands to the mongod service on a regular basis with your own timed script.

Set MongoDB boot self-startup http://www.linuxidc.com/Linux/2011-07/39149.htm under Linux

CentOS compilation and installation of MongoDB http://www.linuxidc.com/Linux/2012-02/53834.htm

CentOS compiles and installs MongoDB and mongoDB's php extension http://www.linuxidc.com/Linux/2012-02/53833.htm

CentOS 6 uses yum to install MongoDB and server-side configuration of http://www.linuxidc.com/Linux/2012-08/68196.htm

Install MongoDB2.4.3 http://www.linuxidc.com/Linux/2013-05/84227.htm under Ubuntu 13.04

MongoDB must-read (both conceptual and practical) http://www.linuxidc.com/Linux/2013-07/87105.htm

English version of the authoritative Guide to MongoDB (MongoDB: The Definitive Guide) [PDF] http://www.linuxidc.com/Linux/2012-07/66735.htm

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

Wechat

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

12
Report