I’m trying to migrate data between two MongoDB 7.0.14 clusters using the mongosync
tool.
First, I run mongosync
with the following command:
mongosync --cluster0 "mongodb://177.171.77.747:27017,mongodb://177.171.77.747:27018"
--cluster1 "mongodb://10.10.10.10:27017,mongodb://10.10.10.11:27018"
--logPath /var/log/mongosync
--verbosity INFO
Where "mongodb://177.171.77.747:27017,mongodb://177.171.77.747:27018"
is proxied via HAProxy.
Then, I start the migration process with the following command:
curl localhost:27182/api/v1/start -XPOST --data '
{
"source": "cluster0",
"destination": "cluster1"
} '
However, during the migration process, I’m encountering the following error:
{ "success": false, "error": "NonEmptyDestinationCluster", "errorDescription": "Found existing data on the destination cluster. The destination cluster must be empty. Drop existing data on the destination and start the migration again." }
Logs:
{"time":"2024-09-03T15:59:48.139087+02:00","level":"info","serverID":"626f6e22c","mongosyncID":"coordinator","message":"Successfully initialized source and destination clients"} {"time":"2024-09-03T15:59:48.228540+02:00","level":"info","serverID":"626f6e22c","mongosyncID":"coordinator","message":"Preflight checks completed."} {"time":"2024-09-03T15:59:48.228582+02:00","level":"info","serverID":"626f6e22c","mongosyncID":"coordinator","message":"Validating source cluster."} {"time":"2024-09-03T15:59:48.244629+02:00","level":"info","serverID":"626f6e22c","mongosyncID":"coordinator","message":"Validating destination cluster."} {"time":"2024-09-03T15:59:48.259452+02:00","level":"info","serverID":"626f6e22c","mongosyncID":"coordinator","message":"Checking compatibility of migration filter."} {"time":"2024-09-03T15:59:48.259476+02:00","level":"info","serverID":"626f6e22c","mongosyncID":"coordinator","message":"Finished checking compatibility of migration filter."} {"time":"2024-09-03T15:59:48.405231+02:00","level":"info","serverID":"626f6e22c","mongosyncID":"coordinator","status":200,"body":"{"success":false,"error":"NonEmptyDestinationCluster","errorDescription":"Found existing data on the destination cluster. The destination cluster must be empty. Drop existing data on the destination and start the migration again."}","traceID":"9289b8153-af818-49aa-9a2b-b2ba5d7ac3b0","latency":"429.086585ms","message":"sent response"}
What I’ve Tried:
-
Dropping the entire database on the destination cluster. However, the error persists even after the database is completely removed.
-
Removing and reinitializing the replica set on the destination cluster, but I still encounter the same error.
-
Trying different versions of
mongosync
, including 1.8, 1.7, and 1.6. The error remains the same across all versions.
Is there a way to bypass this check or what could be the problem?
Is there another recommended approach for migrating mongo data? What are the best methods of data synchronization in clusters? Any suggestions on how to fix this would be greatly appreciated.