I am using mongodb with replica set ,which have 3 nodes lets their ip's are 192.168.1.100 , 192.168.1.101,192.168.1.102 .
In MY current setup 192.168.1.100 is Primary and others are Secondary .I have set priority for 192.168.1.100 and 192.168.1.101 is 1 and for 192.168.1.102 is 0 , now After some time my 192.168.1.100 and 192.168.1.101 both node are down .
I want to force 192.168.1.102 to become primary so that My application will live . Is their is any way to Forcefully convert 192.168.1.102 node to become primary NODE.
You can achieve it without mongod service restart by below steps-
connect to active member suppose it is running on localhost on 27017 port:
mongo --port 27017
Get your member ids from here-
> use admin
> rs.status()
Suppose your active member id is 1. then reconfigure your replication as per below steps-
> cfg = rs.conf()
> cfg.members = [cfg.members[1]]
> rs.reconfig(cfg, {force : true})
It will make your remiaining active member to primary and available for application and writes.
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