All Products
Search
Document Center

Data Transmission Service:Migrate data from an ApsaraDB for MongoDB instance to a Lindorm instance

Last Updated:Mar 28, 2026

Use Data Transmission Service (DTS) to migrate data from an ApsaraDB for MongoDB replica set or sharded cluster instance to a Lindorm wide table instance. DTS supports full data migration and incremental data migration, so you can migrate without stopping your application.

Choose a migration type

Select a migration type based on whether your application can tolerate downtime.

Migration typeWhen to useDowntime required
Full data migration onlyYour application can tolerate a maintenance window. Stop writes to the source before migrating.Yes — stop writes during migration
Full + incremental data migrationYour application must stay online during migration. DTS syncs ongoing changes until you cut over.No — cut over at any time
Important

If you select full data migration only, stop writing to the source database before the task starts. Writing to the source during a full-only migration causes data inconsistency.

Prerequisites

Before you begin, make sure:

For sharded cluster sources:

  • Shard node endpoints are configured and all shard nodes share the same account and password. See Apply for an endpoint for a shard.

  • The _id field in all collections to migrate is unique across shards.

  • The number of Mongos nodes does not exceed 10.

For incremental data migration:

  • To migrate UPDATE and DELETE operations, add a non-primary key column named _mongo_id_ to the Lindorm wide table before starting the task:

    • SQL-created table: The column data type must match the _id column type in the source MongoDB instance. Create a secondary index on this column.

    • Apache HBase API-created table: The column must belong to column family f. The data type must match the _id column type. Create a secondary index on this column. If you want to add additional columns and use the ETL feature, make sure that the Lindorm instance does not contain duplicate data.

  • The oplog feature is enabled on the source database, and operation logs are retained for at least 7 days. Alternatively, change streams are enabled and DTS can subscribe to changes from the last 7 days.

If the wide table is created using the Apache HBase API, create column mappings before configuring the migration task. See Add column mappings for an Apache HBase API table.

Billing

Migration typeTask configuration feeData transfer fee
Full data migrationFreeFree, unless Connection Type is set to Public IP Address (Internet traffic is charged). See Billable items.
Incremental data migrationCharged. See Billing overview.

Migration types

Migration typeDescription
Full data migrationDTS migrates the existing data of the objects to be migrated from the source ApsaraDB for MongoDB instance to the destination Lindorm instance.
Note

DTS supports full data migration for databases and collections.

Incremental data migrationAfter full data migration is complete, DTS migrates incremental data from the source ApsaraDB for MongoDB instance to the destination Lindorm instance. Only INSERT, UPDATE, and DELETE operations on documents are migrated. For UPDATE operations, only updates from $set are migrated.

Permissions required

DatabaseFull data migrationIncremental data migration
Source ApsaraDB for MongoDBRead on the source databaseRead on the source database, the admin database, and the local database
Destination Lindorm instanceRead and writeRead and write

See Manage the permissions of MongoDB database users and Manage users.

Migrate data from MongoDB to Lindorm

The following procedure uses a wide table created with Lindorm SQL statements as the example.

Step 1: Open the Data Migration page

Use one of the following methods:

DTS console

  1. Log on to the DTS console.DTS console

  2. In the left-side navigation pane, click Data Migration.

  3. In the upper-left corner, select the region where the data migration instance resides.

DMS console

The actual steps may vary based on the mode and layout of the DMS console. See Simple mode and Customize the layout and style of the DMS console.
  1. Log on to the DMS console.DMS console

  2. In the top navigation bar, go to Data + AI > DTS (DTS) > Data Migration.

  3. From the drop-down list next to Data Migration Tasks, select the region where the data migration instance resides.

Step 2: Configure source and destination databases

Click Create Task, then configure the parameters described in the following tables.

Source database parameters

ParameterDescription
Task NameA name for the DTS task. DTS generates a name automatically. Specify a descriptive name that makes it easy to identify the task. The name does not need to be unique.
Select Existing ConnectionIf the MongoDB instance is already registered with DTS, select it from the list. DTS fills in the connection parameters automatically. Otherwise, configure the parameters below.
Database TypeSelect MongoDB.
Connection TypeSelect Cloud Instance.
Instance RegionThe region where the source ApsaraDB for MongoDB instance resides.
Replicate Data Across Alibaba Cloud AccountsSelect No.
ArchitectureThe architecture of the source instance. Select Replica Set for this example. If the source uses a sharded cluster architecture, also configure Shard Account and Shard Password.
Migration MethodHow DTS obtains incremental changes from the source. Oplog (recommended) — available if the oplog feature is enabled. By default, the oplog feature is enabled for ApsaraDB for MongoDB instances. Use this method for low-latency incremental migration. ChangeStreamChange Streams — available if change streams are enabled. Required for inelastic Amazon DocumentDB clusters. Requires MongoDB V4.0 or later. If Sharded Cluster is selected for Architecture, you do not need to configure Shard account and Shard password when using this method.
Instance IDThe ID of the source ApsaraDB for MongoDB instance.
Authentication DatabaseThe database that stores the account and password. Default value: admin.
Database AccountThe database account for the source instance.
Database PasswordThe password for the database account.
EncryptionSelect Non-encrypted, SSL-encrypted, or Mongo Atlas SSL based on your requirements. Available options depend on the Connection Type and Architecture selections. The options shown in the DTS console apply. Restriction: If Architecture is Sharded Cluster and Migration Method is Oplog, SSL-encrypted is unavailable.

Destination database parameters

ParameterDescription
Select Existing ConnectionIf the Lindorm instance is already registered with DTS, select it from the list. Otherwise, configure the parameters below.
Database TypeSelect Lindorm.
Connection TypeSelect Alibaba Cloud Instance.
Instance RegionThe region where the destination Lindorm instance resides.
Instance IDThe ID of the destination Lindorm instance.
Database AccountThe database account for the destination Lindorm instance.
Database PasswordThe password for the database account.

Step 3: Test connectivity and proceed

Click Test Connectivity and Proceed at the bottom of the page.

DTS must be able to access both the source and destination databases. Make sure DTS server CIDR blocks are added to the security settings of both databases. See Add the CIDR blocks of DTS servers. If the source or destination is a self-managed database not accessed via Alibaba Cloud Instance, click Test Connectivity in the CIDR Blocks of DTS Servers dialog box.

Step 4: Configure objects to migrate

On the Configure Objects page, set the following parameters.

Migration types and objects

ParameterDescription
Migration TypesSelect Full Data Migration for a one-time migration. Select both Full Data Migration and Incremental Data Migration to keep the source and destination in sync during migration and minimize downtime.
Processing Mode of Conflicting TablesNo configuration required.
Capitalization of Object Names in Destination InstanceThe capitalization policy for database and collection names in the destination. Default: DTS default policy. See Specify the capitalization of object names in the destination instance.
Source ObjectsSelect the collections to migrate and click 向右小箭头 to move them to Selected Objects.

Configure selected objects

For each collection in Selected Objects, configure the schema name, table name, and column mappings.

The following example shows how a source MongoDB document maps to a Lindorm wide table row:

Source document (ApsaraDB for MongoDB)

{
  "_id": "62cd344c85c1ea6a2a9f****",
  "person": {
    "name": "neo",
    "age": "26",
    "sex": "male"
  }
}

Destination table row (Lindorm)

Column nameTypeValue expression
idSTRINGbson_value("_id")
person_nameSTRINGbson_value("person","name")
person_ageBIGINTbson_value("person","age")

To configure the schema, table name, and column mappings:

  1. Edit the schema name:

    1. In Selected Objects, right-click the database that contains the collections.

    2. In the Edit Schema dialog box, enter the database name to use in the Lindorm instance in the Schema Name field. image.png

    3. (Optional) In Select DDL and DML Operations to Be Synchronized, select the operations to migrate during incremental data migration.

    4. Click OK.

  2. Edit table names:

    1. In Selected Objects, right-click a collection.

    2. In the Edit Table Name dialog box, enter the table name to use in the Lindorm instance in the Table Name field. image.png

    3. (Optional) Specify filter conditions. See Specify filter conditions.

    4. (Optional) In Select DDL and DML Operations to Be Synchronized, select the operations to migrate during incremental data migration.

  3. Map source fields to destination columns: DTS automatically maps each field in the source collection using a bson_value() expression and assigns it to a column. In the bson_value() expression, the field name inside "" is the field name in the source MongoDB instance. For example, bson_value("age") maps the age field. (Optional) Click the image icon next to a column to remove fields that do not need to be migrated. Check that the bson_value() expression matches the required destination columns:

    1. In the bson_value() expression in the Assign Value column, check the field name from MongoDB.

      The field within "" is the field name in MongoDB. For example, if the expression is bson_value("age"), this expression maps the age field in MongoDB.

    2. (Optional) Click the image icon next to a column to remove fields that do not need to be migrated.

      Note

      To delete a field that you do not need to migrate, click image in the row of the field.

    3. Configure the fields to be migrated.

      Perform the next steps based on whether the bson_value() expression meets your requirements.

      Fields for which the expression meets requirements

      1. Enter the Column Name for the destination table.

        Note
        • For SQL-created tables: use the column names defined in the table.

        • For Apache HBase API-created tables: use ROW for the primary key column, and Column family:Column name format (for example, person:name) for other columns. Create column mappings first. See Add column mappings for an Apache HBase API table.

      2. Select the Type for the column data.

        Important

        The data type of the destination column must be compatible with the source field type.

      3. (Optional) Set Length and Precision.

      4. Repeat these steps to map all required fields.

      Fields for which the expression does not meet requirements

      Note

      For example, fields that have a hierarchical structure (parent-child structure).

      1. Click the image icon next to the column.

      2. Click + Add Column. image

      3. Set Column Name, Type, Length, and Precision.

      4. In the text box under Assign Value, enter a bson_value() expression. For more information, see Value assignment example.

        Important
        • Always assign the primary key column as bson_value("_id").

        • For nested fields, specify both the field and subfield in the expression — for example, bson_value("person","name"). Using only bson_value("person") causes data loss for subfields.

      5. Repeat for each field.

  4. Click OK.

Step 5: Configure advanced settings

Click Next: Advanced Settings and configure the following parameters.

ParameterDescription
Dedicated Cluster for Task SchedulingBy default, DTS schedules tasks to the shared cluster. For higher stability, purchase a dedicated cluster. See What is a DTS dedicated cluster.
Retry Time for Failed ConnectionsThe retry window when the source or destination database is unreachable. Valid values: 10–1,440 minutes. Default: 720 minutes. Set this to at least 30 minutes. If DTS reconnects within this window, migration resumes automatically. If not, the task fails.
Retry Time for Other IssuesThe retry window for DDL or DML operation failures. Valid values: 1–1,440 minutes. Default: 10 minutes. We recommend that you set the parameter to a value greater than 10. This value must be smaller than Retry Time for Failed Connections.
Enable Throttling for Full Data MigrationThrottle the read/write rate during full migration to reduce load on the source and destination. Configure QPS (queries per second to source), RPS of Full Data Migration, and Data migration speed for full migration (MB/s). Available only when Full Data Migration is selected.
Only one data type for primary key _id in a table of the data to be synchronizedSpecifies whether the _id field has a single consistent data type across all documents in the collection. Yesalert notification settings — DTS skips data type scanning during full migration. No — DTS scans the _id data type during full migration. Available only when Full Data Migration is selected. Enable based on your data. Incorrect settings may cause data loss.
Enable Throttling for Incremental Data MigrationThrottle the incremental migration rate. Configure RPS of Incremental Data Migration and Data migration speed for incremental migration (MB/s). Available only when Incremental Data Migration is selected.
Environment TagAn optional tag to identify the DTS instance.
Configure ETLEnable the extract, transform, and load (ETL) feature to transform data during migration. Yes — enter data processing statements in the code editor. See Configure ETL in a data migration or data synchronization task. No — disable ETL. For Apache HBase API-created tables, use the ETL script to specify which columns to migrate. By default, all top-level fields go to column family f. Example: script:e_expand_bson_value("*", "_id,name") writes all fields except _id and name as dynamic columns. DTS does not migrate additional columns or columns not included in the ETL task. If you add extra columns and use ETL, make sure the Lindorm instance does not contain duplicate data.
Monitoring and AlertingConfigure alerts for task failures or high migration latency. Yes — set an alert threshold and notification contacts. See Configure monitoring and alerting when you create a DTS task. No — no alerting.

Step 6: Run precheck and save settings

Click Next: Save Task Settings and Precheck.

To view the API parameters for this task configuration before saving, move the pointer over Next: Save Task Settings and Precheck and click Preview OpenAPI parameters.

DTS runs a precheck before starting the migration. Address any precheck failures:

  • For failed items: click View Details, fix the issue, then click Precheck Again.

  • For alert items:

    • If the alert cannot be ignored, fix the issue and run the precheck again.

    • If the alert can be ignored, click Confirm Alert Details > Ignore > OK, then click Precheck Again. Ignoring alerts may result in data inconsistency.

Step 7: Purchase and start the instance

  1. Wait until the Success Rate reaches 100%, then click Next: Purchase Instance.

  2. On the Purchase Instance page, configure the following parameters:

    ParameterDescription
    Resource GroupThe resource group for the data migration instance. Default: default resource group. See What is Resource Management?
    Instance ClassThe migration throughput tier. Higher classes provide faster migration. See Instance classes of data migration instances.
  3. Read the Data Transmission Service (Pay-as-you-go) Service Terms and select the check box.

  4. Click Buy and Start, then click OK in the confirmation dialog.

Verify migration status

On the Data Migration page, check the task status:

  • Full data migration only: The task stops automatically when complete. The status changes to Completed.

  • Full + incremental data migration: The incremental migration runs continuously without stopping. The status shows Running. Stop or release the task manually when you are ready to cut over to the destination database.

Important

Before switching workloads to the destination database, stop or release any failed tasks. Alternatively, run REVOKE to revoke write permissions from the DTS accounts on the destination database. If you skip this step and DTS auto-resumes a failed task within 7 days, data from the source may overwrite data in the destination.

Limitations

Source database limitations

  • The source server must have sufficient outbound bandwidth. Insufficient bandwidth reduces migration speed.

  • Collections must have PRIMARY KEY or UNIQUE constraints, and all fields must be unique. Otherwise, duplicate records may appear in the destination.

  • DTS cannot migrate data from the admin, config, or local databases.

  • DTS cannot connect to MongoDB over an SRV endpoint.

  • If you select collections as migration objects and rename them, a single task can migrate up to 1,000 collections. Exceeding this limit causes a request error. Split the migration into multiple tasks.

Full data migration limitations

  • Do not perform schema changes on databases or collections during full data migration, including updates to array types. Schema changes cause task failures or data inconsistency.

  • Do not write data to the source database if you are running full data migration only. Writing to the source causes data inconsistency.

  • Concurrent INSERT operations during full migration cause fragmentation in destination collections. The storage used by destination collections will be larger than in the source.

Incremental data migration limitations

  • Only INSERT, UPDATE, and DELETE operations on documents are migrated. For UPDATE operations, only updates from $set are migrated.

  • The oplog feature must be enabled and operation logs retained for at least 7 days, OR change streams must be enabled and DTS must be able to subscribe to changes from the last 7 days. If these requirements are not met, DTS may fail to obtain operation logs and the task may fail. In exceptional cases, data inconsistency or loss may occur.

  • Use the oplog feature to obtain data changes when possible. Use change streams only if the source runs MongoDB V4.0 or later.

  • Transaction information is not retained. Transactions are converted into a single record.

  • DTS calculates migration latency based on the timestamp of the latest migrated record in the destination and the current timestamp in the source. If no updates occur on the source for an extended period, the latency value may be inaccurate. To refresh the latency, write an update to the source.

Sharded cluster limitations

  • The _id field must be unique across all shards. Duplicate _id values cause data inconsistency.

  • The number of Mongos nodes cannot exceed 10.

  • Do not run the following commands on objects being migrated while the task is running: shardCollection, reshardCollection, unshardCollection, moveCollection, movePrimary. These commands change data distribution and cause data inconsistency.

  • If the Balancer is active in the source sharded cluster, it may cause migration latency.

Lindorm destination limitations

  • The destination Lindorm instance cannot contain collections with a column named _id or _value. If such columns exist, the task fails.

  • Migrated data must comply with Limits on data requests.

  • FLOAT precision defaults to 38 digits; DOUBLE precision defaults to 308 digits. DTS uses ROUND(COLUMN,PRECISION) to retrieve these values. Verify that precision settings meet your business requirements before starting the migration.

  • If the source contains TTL indexes, data inconsistency may occur after migration.

Azure Cosmos DB and Amazon DocumentDB limitations

  • For Azure Cosmos DB for MongoDB clusters and Amazon DocumentDB elastic clusters: only full data migration is supported.

  • For inelastic Amazon DocumentDB clusters: enable change streams and set Migration Method to ChangeStream and Architecture to Sharded Cluster.

Other operational notes

  • Evaluate the impact of migration on source and destination database performance before starting. Run the migration during off-peak hours when possible. Full data migration uses read and write resources on both databases and may increase server load.

  • If a DTS task fails, DTS technical support attempts to restore it within 8 hours. During restoration, the task may restart and parameters may be modified. Only DTS task parameters are modified — database parameters are not changed. Parameters that may be modified include those described in Modify the parameters of a DTS instance.

Example of adding column mappings for a table created by calling the Apache HBase API

The Lindorm instance engine version must be 2.4.0 or later.

In this example, SQL Shell is used.

  1. Create a column mapping for the table:

    ALTER TABLE test MAP DYNAMIC COLUMN f:_mongo_id_ HSTRING/HINT/..., person:name HSTRING, person:age HINT;
  2. Create a secondary index on the _mongo_id_ column:

    CREATE INDEX idx ON test(f:_mongo_id_);

Example of configuring an ETL task for a table created by calling the Apache HBase API

Source document in ApsaraDB for MongoDB

{
  "_id": 0,
  "person": {
    "name": "cindy0",
    "age": 0,
    "student": true
  }
}

ETL script

script:e_expand_bson_value("*", "_id")

Migration result

Migration result

Example of value assignment

Source document structure

{
  "_id": "62cd344c85c1ea6a2a9f****",
  "person": {
    "name": "neo",
    "age": "26",
    "sex": "male"
  }
}

Destination table schema

Column nameType
idSTRING
person_nameSTRING
person_ageINT

Column assignment configuration

Important

Specify both the field and subfield in the bson_value() expression for nested fields. For example, using bson_value("person") alone does not migrate subfields such as name, age, and sex — it only references the parent field. This causes data loss or task failure.

Column nameTypeValue expression
idSTRINGbson_value("_id")
person_nameSTRINGbson_value("person","name")
person_ageBIGINTbson_value("person","age")