Hello,
I have a two node P/S replica set with the following configuration. I have a constrained environment and I’m unable to deploy a third node - arbiter or secondary. I understand that manual failover is the only option for a two-node replica set. I also understand that this is not a recommended deployment model.
The following configuration has node ‘mongodb1’ backing up to ‘mongodb2’. In the event that ‘mongodb1’ fails, I’d like to manually force ‘mongodb2’ to become the active primary.
rs.conf(): {
_id : "rs0",
members: [
{ _id: 0, host: 'mongodb1:27017', priority: 1, votes: 1},
{ _id: 1, host: 'mongodb2:27017', priority: 0, votes: 0 }
]
}
I have a couple of questions regarding this configuration.
Q1) Is this a “safe” configuration in the sense that the replica set will properly backup data from primary to secondary with ‘mongodb2’ backing up ‘mongodb1’?
Q2) Is the following command mongosh sequence a “safe” method initiating a manual failover to force ‘mongodb2’ to become primary? In particular, I’m wondering there are side effects to using {force: true} to update the replica set configuration on a secondary node?
cfg = rs.conf()
cfg.members[0].priority = 0
cfg.members[0].votes = 0
cfg.members[1].votes = 1
cfg.members[1].priority = 1
rs.reconfig(cfg, {force:true})
By “safe” I mean 1) no data corruption on primary/secondary and 2) no writes are lost while a primary node is ‘active’. (Clients will have to retry writes if there are no active primary nodes.)
Best Regards,
Matt