Reconfigure replica set member with same coonfiguration as it was earlier:
We have replica set of three node cluster.
1 Primary P1:27001
2 Secondary S1:27002 and S2:27003
S1 server got crashed and need to rebuilt so mongoDB reconfiguration required.
Status at primary looks like this:
"set" : "rep1A",
"myState" : 1,
"syncingTo" : "P1:27001",
"members" : [
{
"_id" : 0,
"name" :
"P1:27001",
"health" : 1,
"state" : 1,
"stateStr" :
"PRIMARY",
},
{
"_id" : 1,
"name" :
"S1:27002",
"health" : 1,
"state" : 8,
"stateStr" :
"(not reachable)",
},
{
"_id" : 2,
"name" :
"S2:27003",
"health" : 1,
"state" : 2,
"stateStr" :
"SECONDARY",
}
Secondary node S1 got crashed, so required to reconfigure in order to make it the part of replica again.
Few things need to be taken care here is:
replica set name, the port on which process running and the type (Secondary or Arbiter)
Here we have secondary node.
For the configuration file we have copied the configuration file from the Primary P1 node and make the required changes like Port.
Create all the required directories as mentioned in the conf file.
Conf file may look like this:
dbpath= /data/mongod
pidfilepath = /data/mongod/mongod.pid
logpath = /admin/logs/mongod.log
logappend = true
fork = true
shardsvr = true
port = 27002
replSet = rep1A
auth = true
keyFile = /admin/conf/mongo.key
Key file is something we need to copy from Primary node to the secondary node, so they can communicate.
Once all configuration set, we just need to start the mongod process.
The secondary node state will change to STARTUP>STARTUP2>SECONDARY
You can check the status from Primary.
Comments
Post a Comment