top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

MongoDB: Migrating a single database with zero downtime

+4 votes
293 views

I have a replica set with multiple databases. One of the databases is consuming too much resource and I need to migrate it to a new replica set. The requirement is to perform this migration with zero downtime. Has anyone had similar experience, or can give pointers on how to do this?

posted Aug 13, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

So first of all you should never run mongodb as a single instance for production. At a minimum you should have 1 primary, 1 secondary and 1 arbiter.

Second, even with a replica set you will always have a bit of write downtime when you switch primaries, as writes are not possible during the election process. From the docs:

IMPORTANT Elections are essential for independent operation of a replica set; however, elections take time to complete. While an election is in process, the replica set has no primary and cannot accept writes. MongoDB avoids elections unless necessary.
Elections are going to occur when for example you bring down the primary to move it to a new server or virtual instance, or upgrade the database version (like going from 2.4 to 2.6).

You can keep downtime to a minimum with an existing replica set by setting the appropriate options to allow queries to run against secondaries. Again from the docs:

Maintaining availability during a failover. Use primaryPreferred if you want an application to read from the primary under normal circumstances, but to allow stale reads from secondaries in an emergency. This provides a “read-only mode” for your application during a failover.
This takes care of reads at least. Writes are best dealt with by having your application retry failed writes, or queue them up.

Regarding your standalone the documented procedures for converting to a replica set are well tested and can be completed very quickly with minimal downtime:
For more info!

answer May 31, 2017 by Manikandan J
Similar Questions
+1 vote

I have an application that will store data in a an entity called Department.For this department i will have SUBDEPARTMENT1, SUBDEPARTMENT2 and SUBDEPARTMENT3 Now, I want to store massive data in database.those data are students. In RDBMS.the modelisation is simple. Just having one Entity called department and the 3 subdepartment will inherit from the father department. Can you please tell me how to model this in MongoDB?

I know subCollection but it does not look good because I will have also a collection called department that i will be able to store data in it.

+4 votes

I want to know while upgrading/migrating from Apache Hadoop 1.x to 2.x(MRv2YARN) in a production cluster of several nodes is there any *ANTICIPATED DOWNTIME* that one needs to be aware of?

...