Q:

Last mongo replica set becomes secondary?

I have 3 mongo nodes set up as replica sets. The following scenario is occurring:

Node 1 is primary, node 2 is secondary, node 3 is secondary.
Nodes 2 and 3 get shut down.
Node 1 becomes secondary.

This doesn't make sense to me...I would expect the primary to remain primary. Can someone explain this to me? I've read that perhaps I need an arbiter to make the election in the case that only a single node survives, however this feels clunky. Why can't a single node make the election?

A:

With a 3 node replicaset you need a minimum of 2 nodes up.  The docs refer to a 'majority' required to elect a new primary.  Therefore with a 3 node RS, there needs to be at least 2 nodes running for one node to be assigned as primary.
This page has a quite useful table showing the fault tolerance for replicasets with different numbers of nodes:
https://docs.mongodb.org/manual/core/replica-set-architectures/

