It sometimes happens that the MongoDB replica set node goes out of sync from replica set members and, due to high lag, cannot synchronise itself from the replica set. There are traditional ways to remove the replica set node from the cluster and add it back but the issue arises when your database size is too big and node sync takes hours or days. Also in some cases, it degrades the performance. You simply use the following steps and rebuild your replica set member in a few minutes.
Step1
Remove the node from cluster
Prod:PRIMARY> rs.remove(":27017")
Step2
login to ssh to Secondary Node and delete all the content of mongodb directory folder
Step3
Log in to the Primary node. If you donβt know who is primary run this command rs. slave(ok) from any node and then run rs.status(). rs. status will give you the [rimary node IP address or Hostname. Just ssh or login to primary and shut the MongoDB services
--Stop MongoDB
Read more: https://thedbadmin.com/how-to-rebuild-mongodb-replica-set-node-fast-in-few-minutes/
Top comments (0)