Mongodb – Preventing mongodb crashes

mongodb

I am using mongodb with the web server.

Recently, I observed that mongodb server crashed after "no space left" for journalling.

So, after some online help I could repair and restart the DB.

But, for production, I am worried now.

Is there a way in mongodb – when bound to one machine – to truncate the journal files and prealloc files to get truncated without restart of mongodb or any other manual intervention?

Best Answer

The journal will be 3 x 1GB files by default, so really you should just make sure that you have at least 3GB space for the journal when you are starting up. You can use the smallfiles option to reduce that to 3 x 128MB (384MB) instead, however I would not recommend that for any system with significant volume.

Similarly you can turn off pre-allocation using the noprealloc option but again I would not recommend doing so due to the potential performance issues you can hit as a result.

Both of these options must be configured when the process starts, there is no way to (re)configure them after the fact.