mongo_rplset_addarbit

Overview

Arbiter in Mongo is a server who doesn't hold a data, BUT can vote when a new primary should be elected. As such setting an arbiter is again (like everything in Mongo) fairly easy setting as follows:

Starting a mongo instance as part of a replica set was already discussed but we can show it again.

Arbiter server(e.g. lpardmongo)

[root@lpardmongo mongo]#  mongod -f /etc/mongod.conf -fork --replSet testset
about to fork child process, waiting until server is ready for connections.
forked process: 1747
child process started successfully, parent exiting
[root@lpardmongo mongo]# 

On the primary issue the following command to add the arbiter:

Check Current Configuration

[root@lparbmongo ~]# mongo --port 9005
MongoDB shell version: 2.6.12
connecting to: 127.0.0.1:9005/test
testset:PRIMARY> rs.status()
{
        "set" : "testset",
        "date" : ISODate("2018-03-25T18:20:22Z"),
        "myState" : 1,
        "members" : [
                {
                        "_id" : 0,
                        "name" : "lparamongo:9005",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 16542,
                        "optime" : Timestamp(1521930007, 1),
                        "optimeDate" : ISODate("2018-03-24T22:20:07Z"),
                        "lastHeartbeat" : ISODate("2018-03-25T18:20:22Z"),
                        "lastHeartbeatRecv" : ISODate("2018-03-25T18:20:22Z"),
                        "pingMs" : 0,
                        "syncingTo" : "lparbmongo:9005"
                },
                {
                        "_id" : 1,
                        "name" : "lparbmongo:9005",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 16556,
                        "optime" : Timestamp(1521930007, 1),
                        "optimeDate" : ISODate("2018-03-24T22:20:07Z"),
                        "electionTime" : Timestamp(1521985532, 1),
                        "electionDate" : ISODate("2018-03-25T13:45:32Z"),
                        "self" : true
                },
                {
                        "_id" : 2,
                        "name" : "lparcmongo:9005",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 16285,
                        "optime" : Timestamp(1521930007, 1),
                        "optimeDate" : ISODate("2018-03-24T22:20:07Z"),
                        "lastHeartbeat" : ISODate("2018-03-25T18:20:21Z"),
                        "lastHeartbeatRecv" : ISODate("2018-03-25T18:20:21Z"),
                        "pingMs" : 0,
                        "syncingTo" : "lparbmongo:9005"
                }
        ],
        "ok" : 1
}


Add the arbiter

testset:PRIMARY> rs.addArb("lpardmongo:9005")
{ "ok" : 1 }

Check again

testset:PRIMARY> rs.status()
{
        "set" : "testset",
        "date" : ISODate("2018-03-25T18:20:43Z"),
        "myState" : 1,
        "members" : [
                {
                        "_id" : 0,
                        "name" : "lparamongo:9005",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 16563,
                        "optime" : Timestamp(1522002040, 1),
                        "optimeDate" : ISODate("2018-03-25T18:20:40Z"),
                        "lastHeartbeat" : ISODate("2018-03-25T18:20:42Z"),
                        "lastHeartbeatRecv" : ISODate("2018-03-25T18:20:42Z"),
                        "pingMs" : 0,
                        "syncingTo" : "lparbmongo:9005"
                },
                {
                        "_id" : 1,
                        "name" : "lparbmongo:9005",
                        "health" : 1,
                        "state" : 1,
                        "stateStr" : "PRIMARY",
                        "uptime" : 16577,
                        "optime" : Timestamp(1522002040, 1),
                        "optimeDate" : ISODate("2018-03-25T18:20:40Z"),
                        "electionTime" : Timestamp(1521985532, 1),
                        "electionDate" : ISODate("2018-03-25T13:45:32Z"),
                        "self" : true
                },
                {
                        "_id" : 2,
                        "name" : "lparcmongo:9005",
                        "health" : 1,
                        "state" : 2,
                        "stateStr" : "SECONDARY",
                        "uptime" : 16306,
                        "optime" : Timestamp(1522002040, 1),
                        "optimeDate" : ISODate("2018-03-25T18:20:40Z"),
                        "lastHeartbeat" : ISODate("2018-03-25T18:20:43Z"),
                        "lastHeartbeatRecv" : ISODate("2018-03-25T18:20:43Z"),
                        "pingMs" : 0,
                        "syncingTo" : "lparbmongo:9005"
                },
                {
                        "_id" : 3,
                        "name" : "lpardmongo:9005",
                        "health" : 1,
                        "state" : 7,
                        "stateStr" : "ARBITER",
                        "uptime" : 3,
                        "lastHeartbeat" : ISODate("2018-03-25T18:20:42Z"),
                        "lastHeartbeatRecv" : ISODate("2018-03-25T18:20:43Z"),
                        "pingMs" : 0
                }
        ],
        "ok" : 1
}
testset:PRIMARY>

  • mongo_rplset_addarbit.txt
  • Last modified: 2019/10/18 20:04
  • by 127.0.0.1