Durability is the guarantee that an operation that is committed will survive permanently. MongoDB has highly configurable durability settings, from absolutely no guarantees to completely durable. This section covers:
How MongoDB guarantees durability
How to configure your application and server to give you the level of durability you need
The implications of running without journaling enabled
What MongoDB does not guarantee
MongoDB can ensure data integrity after crashes and hard shutdowns, assuming disk and software are behaving correctly.
Note that relational databases usually use durability to describe transaction persistence. As MongoDB does not support transactions, it is used a bit differently here.
As you perform writes, MongoDB creates a journal that contains the exact disk location and bytes changed for that write. Thus, if the server suddenly stops, on startup the journal can be used to replay any writes that were not flushed to disk before the shutdown.
The data files are flushed to disk every 60 seconds (by default), so the journal only needs to hold around 60 seconds of write data. Journaling preallocates a couple of empty files for this purpose that it puts in /data/db/journal, with the names _j.0, _j.1, and so on.
After you’ve been running MongoDB for a long time, you may look in your journal directory and see something like _j.6217, _j.6218, and _j.6219. These are the current journal files. The numbers will continue to increase the ...