0

I used MongoDB 3.6 and was following MongoDB documentation:

https://docs.mongodb.com/manual/tutorial/resync-replica-set-member

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?

2
  • For a file copy backup you need to include the full contents of the dbPath from your source replica set member and writes needs to be quiesced (mongod shutdown or writes stopped using db.syncLock()). If you are seeing new data files created in the dbPath on the target server, I suspect you have an incomplete copy of the source dbPath.
    – Stennie
    Commented Aug 14, 2019 at 5:39
  • @Stennie: Thanks. Yes, I only copied all folders containing data plus admin, config and local folders. So you mean I will need to copy mongod.locck and all WiredTiger files as well?
    – Ben10
    Commented Aug 14, 2019 at 7:59

2 Answers 2

0

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!

-Anban

2
  • Understand Mongo can do intial sync by delete all data from secondary. However, kept experience issue dba.stackexchange.com/questions/245242/… during this initial sync process. So trying to do a full copy of data as Mongo doc (link in my question) suggested
    – Ben10
    Commented Aug 17, 2019 at 2:46
  • May be your disk is corrupt and requires closer look into it. Can you try to change the sync source and then initiate the re-sync again?
    – Anban
    Commented Aug 19, 2019 at 2:59
0

https://docs.mongodb.com/v4.0/tutorial/resync-replica-set-member/#copy-the-data-files

You can capture the data files as either a snapshot or a direct copy. However, in most cases you cannot copy data files from a running mongod instance to another because the data files will change during the file copy operation.

In this link, maybe you need to stop your primary first then copy all the files then?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.