MongoDB log rotations can cause crashes
CEO & Founder of Server Density.
Published on the 7th January, 2013.
Logging is great for debugging but you have to deal with periodically rotating the files so they don’t become massive. We pipe all our logs into Papertrail so we can search them, doing log rotations every 12 hours for most things.
The ability for MongoDB to log to syslog was added in the 2.2 release so you can allow your system to deal with this. We log to a separate file and use a cron job to rotate the logs instead. The documentation recommends you do this by sending a
SIGUSR1 flag to the Unix process. Doing this can cause the Mongo process to hang or crash.
Until this bug is fixed, you should use the mongo console to run the
mongo admin --eval "printjson(db.runCommand(\"logRotate\"))" --port 27017
This has the same effect but will avoid the crashing bug. It applies to both