3

I have a new backup server I want to add to our mongo replica sets. As far as I can tell its as easy as logging on to the replica sets primary and adding the following command:

rs.add( { host: "mongobackup:10003", priority: 0, votes: 0, hidden: true } )

My understanding is that after doing so the primary should sync all its configuration and data with the new node.

Additionally I have an old backup server I want to remove from the replica set which I looks like all i have to do is type this command into the replica sets primary:

rs.remove( "oldmongobackup:10003" )

Is there anything else I am missing?

rs2:PRIMARY> rs.conf()
{
    "_id" : "rs2",
    "version" : 26,
    "members" : [
        {
            "_id" : 7,
            "host" : "mongo03:10001",
            "arbiterOnly" : false,
            "buildIndexes" : true,
            "hidden" : false,
            "priority" : 20,
            "tags" : {
                "dc" : "maid"
            },
            "slaveDelay" : 0,
            "votes" : 1
        },
        {
            "_id" : 8,
            "host" : "mongo01:10002",
            "arbiterOnly" : false,
            "buildIndexes" : true,
            "hidden" : false,
            "priority" : 10,
            "tags" : {
                "dc" : "maid"
            },
            "slaveDelay" : 0,
            "votes" : 1
        },
        {
            "_id" : 9,
            "host" : "mongo02:10003",
            "arbiterOnly" : true,
            "buildIndexes" : true,
            "hidden" : false,
            "priority" : 1,
            "tags" : {

            },
            "slaveDelay" : 0,
            "votes" : 1
        },
        {
            "_id" : 10,
            "host" : "oldmongobackup:10003",
            "arbiterOnly" : false,
            "buildIndexes" : true,
            "hidden" : true,
            "priority" : 0,
            "tags" : {

            },
            "slaveDelay" : 0,
            "votes" : 1
        }
    ],
    "settings" : {
        "chainingAllowed" : true,
        "heartbeatTimeoutSecs" : 10,
        "getLastErrorModes" : {

        },
        "getLastErrorDefaults" : {
            "w" : 1,
            "wtimeout" : 0
        }
    }
}
  • Please post rs.conf() in the question – RolandoMySQLDBA Jan 29 at 16:29
  • Hi, this has been updated. Thanks – CrazyHorse019 Jan 30 at 8:40
1

The command should be fine to run. Why ???

Each rs.add() and rs.remove() should trigger an election. Since the priorities of the remaining nodes have unique values:

  • _id : 7 as priority : 20
  • _id : 8 as priority : 10
  • _id : 9 as priority : 1

you can say the election is rigged. The primary node should remain the primary.

  • Thanks for your answer, turns out it was as simple as rs.add() and rs.remove(). I have now added the new back up server as a node to all 3 of my replica sets and removed the old server from each replica set. happy days! :) I guess I was worried there was more to it than just that. – CrazyHorse019 Jan 31 at 10:05
  • You should always check rs.conf() anyway. If the priorities were just zeros and ones, an election could possibly freeze the cluster. Since one node is an arbiter, the election of a PRIMARY could be decided properly in this case. Hey, better safe than sorry. Thank you for accepting this answer. – RolandoMySQLDBA Jan 31 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.