My OS = Windows 10
I have installed 2 MongoDB servers (community) on 2 machines in LAN.
Can I maintain a cluster with these 2 servers? Or may be shards?
No. You need three. I recommend you take M103 from MongoDB University for a better understanding.
Hi Winnie,
As @steevej mentioned you will need at least three MongoDB instances available if you plan to create a replica set with high availability and automatic failover. Replica sets require a strict majority of voting members to be available in order to elect and maintain a primary
that accepts writes, so a properly configured replica set with three members would have a fault tolerance allowing 1 member to be unavailable.
You can configure a replica set with only 2 members but that would offer no fault tolerance for writes: if either member is unavailable a 2 member replica set would not have a primary and would be unable to accept writes.
If you only have two machines you could host more than one member of a replica set on the same machine, however that is not a recommended deployment pattern as it compromises availability and those mongod
processes will be competing for the same RAM, CPU, and I/O resources. This would only be advisable for a development or test environment.
A sharded cluster has more processes running (each shard is backed by a replica set and there is also a config server replica set for sharded cluster metadata), so again you would want to have more than two machines.
Do you have specific outcomes you are looking to address with multiple machines? For example, are you trying to improve read or write performance or are you just looking to learn more about MongoDB cluster administration?
Regards,
Stennie
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.