3

The tutorial I found on MongoDB's website suggest installing an odd number of servers. For what it's worth, we're not sharding so it should be a simple setup. For even numbers I would need an arbiter. In our environment, DC1 is always the primary with DC2 being the secondary where we would fail over services in the event DC1 fails. With that said ...

  • If I have six nodes (3 node in each DC), would I need an arbiter?
  • If I have five nodes (3 in DC1 and 2 in DC2), if DC1 fails, wouldn't I need an arbiter in DC2?

I guess my confusion is how to handle failover in the event DC1 fails.

1 Answer 1

4

If I have six nodes (3 node in each DC), would I need an arbiter?

Yes - as Mongo docs mentioned an odd number is ideal.

If you have 6 Nodes and 1 goes down, the remaining 5 will elect a new primary. When 2 go down, 4 will elect a primary. When 3 do go down, you only have 3 left which are no longer a majority and all 3 will become read-only until a 4th node comes back online.

If you have 6 + an arbiter, then the scenario plays out slightly more beneficially. 1 node goes down, 5+1 elect a new primary. 2 go down, 4+1 elect a new primary. 3 go down, 3+1 still has a majority (3+1 / 7) so they can elect a new primary. Finally, when 4 nodes are down you are left with 2 nodes up and 1 arbiter, which is less than the majority (2+1 / 7) so you'll enter into read-only until a new node comes back online.

An odd number gives you one more level of outage before you lose the majority of your voting nodes and an arbiter is a cheap way to gain that benefit.

If I have five nodes (3 in DC1 and 2 in DC2), if DC1 fails, wouldn't I need an arbiter in DC2?

In this config, adding an arbiter would give you an even number, so that's not ideal (see above). However, if DC1 goes down you're also losing your majority automatically and thus down to read-only by default. Although it might seem strange, this is the recommended setup from Mongo.

But why?

You could have 3 in DC1 and 3 in DC2 with an arbiter in DC2, which would allow you to maintain a voting majority in DC2 if DC1 were to completely fail. This works if you want automatic failover into DC2. But if DC2 goes down and a node in DC1 goes down, you also lose DC1 majority and end up with read-only nodes - probably not ideal.

That's why Mongo recommends that you set the priority for nodes in DC2 to 0. In this case you should have 3 nodes + 1 arbiter in DC1 and 3 nodes in DC2. You will need to manually fail over to DC2 if DC1 completely fails, but it gives you the best case scenario as far as keeping DC1 active and primary.

5
  • Makes sense. I guess where I'm confused is how to handle the failover to DC2. If the priority is set to 0, then none of the nodes in DC2 would become primary. I wasn't sure how to get DC2 back online with a master since the secondary nodes are in a read-only state. I don't think you can promote one of the nodes to become primary, no? Would I be able to add a new node as primary and sync it from the secondaries?
    – sdot257
    Commented Feb 26, 2016 at 18:48
  • @luckytaxi In that case you have to remove the DC1 nodes from the replica set, thereby giving you majority again. Commented Feb 26, 2016 at 20:04
  • Got it, i was assuming everything would be automatic.
    – sdot257
    Commented Feb 26, 2016 at 20:49
  • Hello @luckytaxi . I am wondering how the DC1 gets removed from the set if DC1 is completely down? I am facing a similar scenario with 2 nodes in DC1 and 1 in DC2. To simulate a DR I turn off both nodes in DC1 simultaneously. DC2 goes to secondary. Even with one extra Abriter in DC2, I wasn't able to do anything on DC2. How to set the priority or add more abiters such a way that DC2 becomes primary. thanks Commented Nov 23, 2019 at 17:57
  • sorry but it's been a very long time since I've used MongoDB.
    – sdot257
    Commented Dec 16, 2019 at 21:50

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.