MongoDB log Switching

Source: Internet
Author: User
By default, MongoDB does not automatically switch the rotation log, which will increase the number of logs. In the busy business, the log growth volume is very large. It is not convenient to view logs of a certain day for such a large log file. If yes, you need to switch the mongodb log file for 7 days. SIGUSR1 method # kill-SIGUSR1 # finddata

By default, MongoDB does not automatically switch the rotation log, which will increase the number of logs. In the busy business, the log growth volume is very large. It is not convenient to view logs of a certain day for such a large log file. If yes, you need to switch the mongodb log file for 7 days. SIGUSR1 method # kill-SIGUSR1 # find/data/

By default, MongoDB does not automatically switch the rotation log, which will increase the number of logs. In the busy business, the log growth volume is very large. It is not convenient to view logs of a certain day for such a large log file. If yes, you need to switch the mongodb log file for 7 days. SIGUSR1 Method
# kill -SIGUSR1 # find /data/mongodb_data/log/mongodb.log.* -mtime +7 -delete
This method can only be performed in Linux. Mongo logRotate command Method
use admindb.runCommand( { logRotate : 1 } )
It must be run on mongos, mongod, and config server. This method is the only method in Windows. Syslog Rotation
# vi /etc/logrotate.d/mongodb /opt/mongodb/log/mongodb.log {    daily    rotate 7    compress    dateext    missingok    notifempty    sharedscripts    copytruncate    postrotate        /bin/kill -SIGUSR1 `cat /data/mongodb_data/mongod.lock 2> /dev/null` 2> /dev/null || true    endscript}
# logrotate -f /etc/logrotate.d/mongodb
For details about logrotate, see logrotate log management tools. Mongodb bug is not stable enough. In log rotation, the mongodb process is terminated. For details, refer to the mongodb bug system.

Original article address: MongoDB log switch. Thank you for sharing it.

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.