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 management

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

Share

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

# cut out the contents of the log itself and automatically generate new date-generated history files: method 1: mongod-v-- logpath / var/log/mongodb/mongos.log method 2: kill-SIGUSR1 {pid} method 3: use admindb.runCommand ("logRotate") # two kinds of delete the old log file, keep the log file find / var/log/mongodb/mongos.log.*-mtime + 7-exec rm-rf {}\ Find / var/log/mongodb/mongos.log.*-mtime + 7-delete method 4: vim / etc/logrotate.d/mongodb/mongod/config.log {daily # every day rotate 7 # rotation 7 days compress # compress missingok through gzip # ignore this warning notifempty if the log does not exist # do not rollover sharedscripts if the file is empty # script copytruncate that runs only once for the entire log group # for log files that are still open Back up the current log and truncate dateext # use date as the naming format size 200m # log files are saved when they reach the specified size, you can specify K Mpostrotate / bin/kill-SIGUSR1 'cat / mongod/mongod.lock 2 > / dev/null' 2 > / dev/null | | trueendscript # end script} # make the above statement take effect immediately. Logrotate mongodb# script implements automatic log cutting vim / rootDB cutout mongodblog log.shelled logs automatically. '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

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