1

I'm setting up a MongoDB cluster on Amazon EC2 instances and the documentation says...

...for best performance we recommend separate volumes for data files, the journal, and the log. Each has different write behavior, and placing them on separate volumes reduces I/O contention.

Then it follows up with...

Note: Using different storage devices will affect your ability to create snapshot-style backups of your data, since the files will be on different devices and volumes.

But it doesn't say what affect that might be.

I'm guessing that the affect is that it completely removes your ability to do snapshot style backups while the instance is running?

If I were to stop the MongoD service so that the data file, journal and log are no longer being written and snapshot all three, will I still get a safe restorable backup?

1 Answer 1

1

The answer according to Mongo is:

Flush and Lock the Database

Writes have to be suspended to the filesystem in order to make a stable copy of the database files.

Prior to MongoDB version 2.0, this is achieved through the MongoDB shell using fsync and lock:

mongo shell> use admin
mongo shell> db.runCommand({fsync:1,lock:1});
{
   "info" : "now locked against writes, use db.$cmd.sys.unlock.findOne() to unlock",
   "ok" : 1
}

MongoDB 2.0 added the db.fsyncLock() method to lock the database and flush writes to disk and added the db.fsyncUnlock() method to unlock the database after the snapshot has completed.

During the time the database is locked, any write requests that this database receives will be rejected. Any application code will need to deal with these errors appropriately.

How to set Mongo with EC2 is covered here: https://docs.mongodb.org/ecosystem/platforms/amazon-ec2/

And the backup is covered here: https://docs.mongodb.org/ecosystem/tutorial/backup-and-restore-mongodb-on-amazon-ec2/#ec2-backup-and-restore

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .