- Consistent data across two machines
- A normal MongoDB replica set will do this for you, for replica sets the minimum configuration and it’s best to do Primary, Secondary, Secondary. You can read/write to the Primary and Read from the secondary (if you want and your app can afford possible stale data based on replication time).
- Tolerant to failure of one server
- This isn’t possible (at minimum you need 3 which I know you can’t add), replica sets are deployed in odd numbers, so one of the nodes is going to have the majority of MongoDB processes on it so if it goes down your cluster will be READ only. Deploying in even numbers (not recommended) would also have the same issue, if a server goes down you don’t have a majority of processes up.
Lets say:
Server 1 has Primary, Secondary
Server 2 has Secondary
If server 1 goes down the cluster is read only because there will be no primary
If server 2 goes down the cluster will be health and R/W is possible.
Another example of 5 node replica
Server 1 Primary, Secondary, Secondary
Server 2 Secondary, Secondary
Again if Sever 1 goes down you have the same issue.