Many-to-One Migrations
On this page
Important
Cluster-to-Cluster Sync Beta Program
This feature is only available in mongosync
beta. To learn more,
see Cluster-to-Cluster Sync Beta Program.
Starting in mongosync
beta 1.8, you can perform Many-to-One
migrations. Many-to-One migrations allow you to sync multiple source
clusters simultaneously with a destination cluster. For example, you can
consolidate data from many small clusters into a central cluster.
Syntax
To sync multiple source clusters with one destination cluster, run the following commands when starting mongosync:
./bin/mongosync \ --cluster0 <source-A-connection-string> \ --cluster1 <destination-connection-string> \ --migrationName <string> ./bin/mongosync \ --cluster0 <source-B-connection-string> \ --cluster1 <destination-connection-string> \ --migrationName <string>
To start the sync operation between the source clusters and the destination cluster, see Synchronize Data Between Clusters.
Behavior
A namespace is a database_name.collection_name
combination. You can only
sync namespaces that don't conflict.
For example, consider this scenario:
Two source clusters S1 and S2.
A destination cluster D.
Databases named
inventory
andsales
on both S1 and S2.Collections named
products
,orderLines
,orderStatus
, andorders
on both S1 and S2.You can sync both of these combinations:
inventory.products
andsales.orderStatus
on S1 with D.inventory.orderLines
andsales.orders
on S2 with D.
You cannot sync both of these combinations because they conflict:
inventory.products
andinventory.orderLines
on S1 with D. If D is initially empty, you can sync S1 with D.inventory.products
andinventory.orderLines
are copied from S1 to D.inventory.products
andinventory.orderLines
on S2 with D. You cannot sync S2 with D becauseinventory.products
andinventory.orderLines
conflict with the namespaces already on D from the scenario in the previous point.
Migration Name
The migrationName
string can contain up to 44 alphanumeric and underscore
characters. migrationName
is appended to the string
"mongosync_internal_"
to set the migration metadata database name.
For example, if you set migrationName
to
"cluster_27000_to_cluster_35000_sync"
, the resulting mongosync
metadata
database name is "mongosync_internal_cluster_27000_to_cluster_35000_sync"
.
Example
The following example connects source clusters running on port 27000
and 27001
with a destination cluster running on port 35000
. The command
also sets the --migrationName
option to
describe the operations and store migration metadata for each sync.
./bin/mongosync \ --cluster0 "mongodb://localhost:27000" \ --cluster1 "mongodb://localhost:35000" \ --migrationName "cluster_27000_to_cluster_35000_sync" ./bin/mongosync \ --cluster0 "mongodb://localhost:27001" \ --cluster1 "mongodb://localhost:35000" \ --migrationName "cluster_27001_to_cluster_35000_sync"