Mongodb: how to move a member to a backup site

mongodbmongodb-3.4

It is stated in the docs, that any replica set should have an odd number of members. Let's say I have a primary site with 3 members. I need to move one member to a backup site. In order to do this, do I need to first add a new member on the backup site, and them remove a member on the primary site? What is the official procedure? I'm very confused, because by the time the member is added, there will have been an even number of members. Where will I go from there? How dangerous it is to add a single member to a replica set without doing any hanky-panky?

Should I do some magic tricks (e.g. set priorites of particular members to zero) before I add a new member?

Is this documented somewhere?

Best Answer

Where you found that information that replica should have even number of members, because it is ODD number. With even number of members (votes) you could end up situation that you don't have majority. IF you have even number of data nodes, you need arbiter as fifth.

OK, to the question how to move one member. Let's assume that you have three nodes (primary + 2x secondary). If you want to be sure that your replica set stays up even you lost one member during that time that when one secondary is "on-the-move" and not up'n'running, bring one Arbiter to replica set. You can install arbiter to "any" other server, because it will not take resources (basically). You give command rs.addArb("address:port") just before you shutdown that secondary. After you start again that secondary at new location, you give command rs.remove("address:port"). That way you always have three votes online.