I have two clusters of MongoDB which run on 4 servers (2 servers on each cluster). They are the same as collections schema. And now I want to migrate new data from one cluster to another which existing old data.
I need to migrate data from one cluster to another with large data (about 700GB).
I've tried using import/export of MongoDB Compass, DB tools such as mongodump/mongorestore, mongoexport/mongoimport. All of them work as expected for testing. But it is small data. With large data, they will be very slow to export from DB source and import to destination BD. And maybe they will crash while export/import large data. So, What is the best way I can do that? I've an idea to use replica sync mechanism for performance and safe reason.
- Use one mongo server of the source cluster as a Primary instance (server A), and one of the destination clusters as a Secondary instance (server B) and join them on the same replicaset. And the question is 700GB of new data on source server will sync to the destination server without removing existing data by replica sync mechanism or not?
- If step 1 works, after replica sync is complete, I will turn off replicaset between server A and server B and re-config the replica set for 2 servers on destination cluster with server B as Primary instance, and 2nd server of destination cluster as the Secondary instance. New data which be synced on server B will sync to this secondary instance.
That is my idea, and I don't know it will work on large data or not. Have any suggestions for me in my case? Thanks everyone for any suggestions.