MongoDB cross datacenter replication without elections or high data availaility

backupmongodbreplication

I want to replicate a MongoDB database to another node, located in another datacenter.
This is to help guard against data loss in the case of a hardware failure.

We don't want/need high availability or elections; just a 'close to live' read-only copy of the database, located in another DC.

Everything I read says that you need an odd number of nodes, due to elections, but this isn't something we need/want and I can't find anything related to just having one primary, and one secondary (I might be being blind).

Is this something we can achieve with MongoDB, and if so are there any 'gotchas' or serious downsides we should consider?

Best Answer

You could created a Replica Set with a Hidden Member. The hidden member will take a read/only copy of your data. However, if the hidden member goes down then the primary steps down to secondary, i.e. your MongoDB becomes read/only.

You can define an Arbiter. It is not necessary to create the Arbiter service on a dedicated host, define it on your primary node. It is just a small mongod service which consumes almost no CPU/memory resources or disc space.

If you have a Primary + Arbiter on one host and the Hidden Secondary on another host then the second may stop and your application continues running normal. Of course, is your primary goes down then the application is not available anymore.