1) I have 3 mongodbs running in a replica set
mongod --fork --logpath a.log --smallfiles --oplogSize 50 --port 27001 --dbpath data/z1 --replSet z
mongod --fork --logpath b.log --smallfiles --oplogSize 50 --port 27002 --dbpath data/z2 --replSet z
mongod --fork --logpath c.log --smallfiles --oplogSize 50 --port 27003 --dbpath data/z3 --replSet z
2) Now 27001 and 27002 are down.
What do I need to do to make 27003 primary without restarting 27001 and 27002?
You have to reconfig the replica set: http://docs.mongodb.org/manual/tutorial/reconfigure-replica-set-with-unavailable-members/
Namely you have to actually go onto that member and run a rs.reconfig to remove those two dead members from the set since you have a majority of the members offline.
Here is how you can do it.
Restart the other two instances after deleting the contents of their dbpath.
Assuming you can not get the other nodes back online (which reminds me a bit of a homework for M102)
replset:SECONDARY> oldConf = rs.conf()
[...]
replset:SECONDARY> conf = {
...
... _id:oldConf._id,
... version: oldConf.version + 1,
... members: [ oldConf.members[2] ]}
[...]
replset:SECONDARY> rs.reconfig(conf,{force:true})
Note: Instead of putting 2 at oldConf.members[2], you need to put in the position of the instance running on port 27013 in oldConfig.members, starting from 0. After you sent the rs.reconfig command, it may take a few seconds for the last node to come up as primary.
Get up two other nodes with the according --replSet parameter and use the procedure described above to add them by adding them to the members array of conf.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With