MongoDB Replica Set Sync data by Copying Data Files from Another Member


I used MongoDB 3.6 and was following MongoDB documentation:

to do a full copy of data from Primary node to another mongod instance. I copied both admin and local plus all database folders into the new node. After all data are ready, added new node into replica set. It seems the replica set starts another initial sync and copy data from Primary to the new node. I got 400 GB data in primary node, so after a few hours Secondary node data size reach 600 GB and no disk space left and cause the sync fail. So it seems MongoDB still copying all data from Primary to Secondary even after I did this data copy manually. More surprisingly, it keeps the data I copied and continue to do its own data sync. Any suggestion?

Best Answer

The way you perform the resync isn't right. To perform resync of the secondary member (assuming it is already a member of the replica set), bring down (stop mongod process) the secondaray node, delete all the folders from the /data directory including journal and restart the node so it re-joins the replica set again

Once it re-joins the replica set, mongodb will automatically copy all the data files including local database to the secondary. You don't need to copy admin or local database manually as mongo will take care of it

Thank you!