I have three 3 node cluster on-premises ( 1 Primary and 2 Secondary ). I have same 3 node cluster in AZURE ( 1 Primary and 2 Secondary ) with same version and data but with different FQDN in azure. How shall I connect mongodb replica set in azure to mongodb replica set in on-premises so that they can start replicating the data. Later I would like to switch off on-premises mongodb and move finally to azure. My question is:

  1. What would be my architecture? Shall I make all the 3 members in azure secondary with hidden:true , priority:0 and add/connect all of them to on-premises?
  2. What configuration changes do I need to make in mongod.conf file both in on-prem and in azure so that communication can be established between the node?

1 Answer 1


Basically, you add those three nodes as secondary to your current on-premise replica set. (rs.add(FQDN)) Not necessary to be hidden, but set priority lower than nodes at the premises, to prevent primary to moving there before you want to do so.

What comes to the communication, check that firewalls are open so that every node can reach each other and your Azure nodes are not "open to the world".

When you want to move primary there, modify rs.conf() so that (one of) Azure nodes have the highest priority, and two azure nodes have the second highest priority. Then "remove" those on-premise nodes from the setup. (rs.remove(FQDN))

  • Do I need to make any changes in the mongod.conf file for example adding IP of azure in on-prem mongod.conf file?
    – amanullah
    Commented Jun 20, 2022 at 5:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.