MongoDB Log Management

Source: Internet
Author: User

#切除本身日志内容并且自动生成新的以日期生成的历史文件方法一: Mongod -v --logpath /var/log/mongodb/mongos.log method Two: kill - Sigusr1 {pid} Method Three: Use admindb.runcommand ("LogRotate") #两种删除旧的日志文件, keep the log file for 7 days find /var/log/mongodb/ mongos.log.* -mtime +7 -exec rm -rf {} \;find /var/log/mongodb/ Mongos.log.* -mtime +7 -delete method Four: vim /etc/logrotate.d/mongodb/mongod/config.log { daily# Daily rotate 7# rotation for 7 days compress# by gzip compression missingok# if the log does not exist then ignore the warning notifempty# if it is empty file does not dump sharedscripts          #只为整个日志组运行一次的脚本copytruncate           #用于还在打开中的日志文件, the current log is backed up and truncated dateext# use date as a named format size 200m# when a log file reaches a specified size, you can specify k,mpostrotate/bin/ kill -sigusr1  ' Cat /mongod/mongod.lock 2>/dev/null '  2> /dev/null | |  trueendscript# End Script} #立即使上面的语句生效logrotate  mongodb# script for automatic cutting of logs vim /root/cut_mongodb_log.sh#!/bin/ Bashdatafile=/mongodb/mongodb_datalogfile=/mongodb/mongodb_logdays=7/bin/kill -sigusr1  ' cat  $datafile/mongod.lock ' find  $logfile / -mtime + $days  -deletechmod +x /root/cut_mongodb_log.shvim /etc/crontab0 0  * * * /root/cut_mongodb_log.shservice crond restartchkconfig crond on


This article is from the "Wu Shanqiang" blog, make sure to keep this source http://shanqiangwu.blog.51cto.com/8067564/1654972

MongoDB Log Management

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.