Reputation: 389
We have a replicaset consisting of a 1 primary and two secondaris. We use mongoDb version 4.2 on a container.
For the purpose of DR, we are now adding a remote site, and I would like to put one of the secondaries on a host in that remote site, instead of on the local site.
I realize that if a set the priority of the member on the remote site to be lower than the priority of the members on the local site (the primary and the secondary), then in case of a failover, the local secondary mamber will be promoted to become the primary, unless it is unavialble too.
I have two questions:
For a new cusotmer where I need to set a new Mongo with a replicaSet, How can I make sure that one of the two members on the local site will be created as the Primary? I there some kind of setting in rs.config that tells that a particular member is to be the Primary?
For an existing replicaSet - the way to "move" a member to a new hots would be to reconfigure the replicaSet with a new host?
Upvotes: 0
Views: 156
Reputation: 14530
Primaries are elected (internally by the replica set), not designated by the administrator. There is an internal command called replSetStepUp
but for normal use, you are supposed to set priorities in accordance with where you want your primary to be.
Given 3 nodes, if you set priorities to 10, 10 and 1 the node with priority of 1 should almost never be the primary (unless, perhaps, it's more current than either of the nodes with priority 10, for example because one died and the other one was seriously behind the majority).
How can I make sure that one of the two members on the local site will be created as the Primary?
And, you can only have one primary at a time.
the way to "move" a member to a new hots would be to reconfigure the replicaSet with a new host?
There is no concept of "moving members" in MongoDB. You can add and remove nodes at any time.
To implement an offsite backup that shouldn't ever be used for normal operations, add a hidden node to the replica set at the offsite location (this would be the 4th node, you would need 3 normal ones in addition to it).
Upvotes: 1