How to avoid data loss during server failure using MongoDB on the same machine?

I read that mongoDB does not write data to disk immediately, it does this periodically.

Any thoughts on how to deal with this?

+6
source share
2 answers

In addition to --journal , which is enabled by default, since MongoDB 2.0 ( only on 64-bit machines), there is a flag that you can set when saving data:

  • safe => false : don't wait for db response
  • safe => true : wait for db response
  • safe => num : wait for many servers to have a record before returning
  • fsync => true : write fsync to disk before returning. fsync => true implies safe=>true , but not vice versa.

If fsync=>false and safe=>true and the record can be successfully applied to the mmapped file, but not yet written to disk

+3
source

Source: https://habr.com/ru/post/898037/


All Articles