MongoDB log file growth

后端 未结 4 518
野性不改
野性不改 2020-12-13 04:45

Currently my log file sits at 32 meg. Did I miss an option that would split the log file as it grows?

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-13 05:19

    Using logrotate is a good option. while, it will generate 2 log files that fmchan commented, and you will have to follow Brett's suggestion to "add a line to your postrotate script to delete all mongod style rotated logs".

    Also copytruncate is not the best option. There is always a window between copy and truncate. Some mongod logs may get lost. Could check logrotate man page or refer to this copytruncate discussion.

    Just provide one more option. You could write a script that sends the rotate signal to mongod and remove the old log files. mongologrotate.sh is a simple reference script that I have written. You could write a simple cron job or script to call it periodically like every 30 minutes.

提交回复
热议问题