I read about the different MongoDB setups for doing backup without downtime. Which strategy is best or can they even be compared?
Enable journaling and simply copy the
/data/db
directory - it is unclear to me if this is enough – on the MongoDB home page it states that you have to "snapshot it" and it works on SAN and LVM as examples.Questions:
What does snapshot mean in this context will a copy command count as a snapshot? Is it save to copy a journaling MongoDB (2.0+) data directory on a Windows server with NTFS? How do you ensure that it is safe to do on your own filesystem and setup?
Establish a replica set with 2 servers and an arbiter. Then use
rs.status()
andfsyncLock
/unlock to ensure data is read only on the secondary server while doing backup.> db.fsyncLock function () { return db.adminCommand({fsync:1, lock:true}); } > db.fsyncUnlock function () { return db.getSiblingDB("admin").$cmd.sys.unlock.findOne(); }
Questions:
If you use locks in a replica set it seems that writes and reads can be locked for the whole replica set and this bug has not been fixed?
What if the secondary is voted in as primary while the backup is in progress? Will the backup process stop or will the replica set stop responding to write requests until it is unlocked?
Considerations:
For now I would like the simple solution and simply copy the
data
/db
directory with journal files and wait with the replica set. MongoDB runs on a 64 bit Windows server (RackSpace Cloud).