0

I have local set up for 3 mongo DB instances with successful replica set. (1 Primary, 2 secondary).

If I terminate Primary instance, one of the secondaries becomes Primary but its taking around 10 seconds.

Is there a way I can reduce the time.

I have updated rs.config as below:

  config = rs.config()
  {
"_id" : "rs0",
"version" : 3,
"protocolVersion" : NumberLong(1),
"members" : [
    {
        "_id" : 0,
        "host" : "127.0.0.1:27020",
        "arbiterOnly" : false,
        "buildIndexes" : true,
        "hidden" : false,
        "priority" : 1,
        "tags" : {

        },
        "slaveDelay" : NumberLong(0),
        "votes" : 1
    },
    {
        "_id" : 1,
        "host" : "127.0.0.1:27021",
        "arbiterOnly" : false,
        "buildIndexes" : true,
        "hidden" : false,
        "priority" : 1,
        "tags" : {

        },
        "slaveDelay" : NumberLong(0),
        "votes" : 1
    },
    {
        "_id" : 2,
        "host" : "127.0.0.1:27022",
        "arbiterOnly" : false,
        "buildIndexes" : true,
        "hidden" : false,
        "priority" : 1,
        "tags" : {

        },
        "slaveDelay" : NumberLong(0),
        "votes" : 1
    }
],
"settings" : {
    "chainingAllowed" : true,
    "heartbeatIntervalMillis" : 1000,
    "heartbeatTimeoutSecs" : 3,
    "electionTimeoutMillis" : 10000,
    "catchUpTimeoutMillis" : 2000,
    "getLastErrorModes" : {

    },
    "getLastErrorDefaults" : {
        "w" : 1,
        "wtimeout" : 0
    },
    "replicaSetId" : ObjectId("5976e7bd5b7837e0fbba2871")
  }
}

EDIT

I have reinstalled MongoDB enterprise edition:

   MongoDB shell version: 3.2.15
1
  • MongoDB shell version v3.4.4
    – Chowdappa
    Jul 27, 2017 at 10:44

3 Answers 3

1

Yes! Check here.

You can adjust

  • settings.heartbeatTimeoutSecs
  • settings.electionTimeoutMillis
  • settings.catchUpTimeoutMillis
  • settings.heartbeatIntervalMillis
1

For those of you who've been running MongoDB since version 3.0 or earlier, you may not have protocolVersion or it may be set to 0. If you are now running versions 3.2.12+ or 3.4+, we recommend you upgrade your RS to use protocolVersion 1. This should greatly increase the speed of electing a new primary.

0

I have updated electionTimeoutMillis to 1 sec. It seems working now.

If someone give me better solution, Really appreciate it.

   "settings" : {
     "chainingAllowed" : true,
    "heartbeatIntervalMillis" : 500,
    "heartbeatTimeoutSecs" : 1,
    "electionTimeoutMillis" : 1000,
    "getLastErrorModes" : {

    },
    "getLastErrorDefaults" : {
        "w" : 1,
        "wtimeout" : 0
    },
    "replicaSetId" : ObjectId("597ad5b9c773dbb20a2c8cca")
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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