Вопрос

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
        }
    }
}
Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с dba.stackexchange
scroll top