MongoDB System Log Start cutting implementation method

Source: Internet
Author: User
Tags system log

When making a MongoDB shard, when the MONGOs routing service is enabled, we specify a location for the log to be stored:

MONGOs--configdb 127.0.0.1:27019--logpath/var/log/mongodb/mongos.log--pidfilepath/var/run/mongodb/mongos.pid-- Logappend--logrotate Reopen--fork

Above we specify the location of the log in the/var/log/mongodb/mongos.log file, when the system data volume is large, after a long run time, the Mongos.log file will become a few g size, which will certainly affect the performance of MONGOs routing.

In this case we can borrow the system logrotate log automatic cutting service, to change the size of the Mongos.log file, into the cd/etc/logrotate.d/ directory, create a file: Touch MONGOs, The editor adds the following content:

/var/log/mongodb/mongos.log{rotate 1 Daily dateext size 200M postrotate/bin/kill-sigusr1 ' Cat/va R/run/mongodb/mongos.pid 2>/dev/null ' 2>/dev/null | | True Endscript}

A simple description of the above configuration:

Size: Specifies that files are automatically cut when the Mongos.log file exceeds 200M

Dateext: Specifies how the backup file is named when the file is cut

Rotate 5:5 archive logs will be stored at a time. For a sixth archive, the oldest archive will be deleted.

Daily: Log file will be polled by day

Postrotate/endscript: After the execution of other commands, execute the command inside.

This article is from the "connected with the Internet" blog, please be sure to keep this source http://suiwnet.blog.51cto.com/2492370/1630994

MongoDB System Log Start cutting implementation method

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.