Entire DB Migration

Scenario

CDM supports entire DB migration between homogeneous and heterogeneous data sources. The migration principles are the same as those in Table/File Migration Jobs. Each type of Elasticsearch or each collection of MongoDB can be executed concurrently as a subtask.

Table 1 lists the data sources supporting entire DB migration using Cloud Data Migration.
Table 1 Supported data sources in entire DB migration

Source Data Type

Destination Data Type

RDS for MySQL

MRS(Hive)

DWS

CSS

OBS

CloudTable

MySQL

√

√

√

×

√

×

PostgreSQL

√

√

√

×

√

×

Microsoft SQL Server

√

√

√

×

×

×

Oracle

√

√

√

×

√

×

Elasticsearch

×

×

×

√

×

×

MongoDB

×

×

×

×

×

×

HBase

×

×

×

×

×

√

IBM Db2

√

√

√

×

√

×

Derecho(Gauss DB)

√

√

√

×

√

×

SAP HANA

√

√

√

×

√

×

DWS

√

√

√

×

×

×

Hive

√

×

√

×

×

×

The source databases can be deployed in on-premises data centers or built on ECSs, or third-party database services.

Field Mapping in Automatic Table Creation

CDM automatically creates tables at the destination during database migration. Figure 1 describes the field mapping between the DWS tables created by CDM and source tables. For example, if you use CDM to migrate the Oracle database to DWS, CDM automatically creates a table on DWS and maps the NUMBER(3,0) field of the Oracle database to the SMALLINT field of DWS.

Figure 1 Field mapping in automatic table creation on DWS 1

Prerequisites

  • You have created links based on the instructions in Creating Links.
  • The CDM cluster can communicate with the data source.

Entire DB Migration

  1. Log in to the DGC console, select a DGC instance, and click Access.

    On the displayed page, click the Workspaces tab. In the workspace list, locate the required workspace.

  1. Click Data Integration of the corresponding workspace.

    The Data Integration page is displayed.

  1. Choose Cloud Data Migration. The Cluster Management page is displayed. Click Job Management in the Operation column of the cluster.
  2. Choose Entire DB Migration > Create Job. The page for configuring the job is displayed.
    Figure 2 Creating an entire DB migration job
  3. Configure the related parameters of the source database according to Table 2.
    Table 2 Parameter description

    Source Database

    Parameter

    Description

    Example Value

    • Oracle
    • MySQL
    • PostgreSQL
    • Microsoft SQL Server

    Schema/Tablespace

    Name of the schema or tablespace from which data will be extracted. This parameter is displayed when Use SQL Statement is set to No. Click the icon next to the text box to go to the page for selecting a schema or directly enter a schema or tablespace.

    If the desired schema or tablespace is not displayed, check whether the login account has the permissions required to query metadata.

    Schema

    WHERE Clause

    WHERE clause used to specify the tables to be extracted. This parameter applies to all subtables in the entire DB migration. If this parameter is not set, the entire table is extracted. If the table to be migrated does not contain the fields specified by the WHERE clause, the migration will fail.

    This parameter can be configured as a macro variable of date and time to extract data generated at a specific date. For details, see WHERE Clause.

    age > 18 and age <= 60

    Elasticsearch

    Index

    Index of the data to be extracted. The value can be a wildcard character. Multiple indexes that meet the wildcard condition can be migrated at a time. For example, if this parameter is set to cdm*, CDM migrates all indexes starting with cdm, such as cdm01, cdmB3, cdm_45 and so on.

    If multiple indexes are migrated at a time, Index at the migration destination cannot be configured.

    cdm*

    MongoDB

    Database Name

    Name of the database from which data is to be migrated. The user configured in the source link must have the permission to read the database.

    mongodb

    Filter Condition

    Advanced attribute parameter.

    This parameter is used to create a filter for matching documents.

    {HTTPStatusCode:{$gt:"400",$lt:"500"},HTTPMethod:"GET"}

  4. Configure the related parameters of the destination cloud service according to Table 3.
    Table 3 Parameter description

    Cloud Service

    Parameter

    Description

    • MRS Hive
    • RDS for MySQL

    Schema/Tablespace

    Database name

    Auto Table Creation

    The options are as follows:
    • Non-auto creation: CDM will not automatically create a table.
    • Auto creation: If no corresponding table exists in the destination database, CDM will automatically create one.
    • Deletion before creation: If a table with the same name exists in the destination database, CDM will delete the table first and create another one with the same name.

    Clear Data Before Import

    Whether to clear the data in the target table before data import. The options are as follows:
    • Do not clear: Do not clear the data in the target table before data import but add data to the table.
    • Clear all data: Clear all data in the target table before data import.
    • Clear part of data: Clear part of data in the target table before data import. If you select Clear part of data, you must configure WHERE Clause to specify the data to be deleted from the target table.

    WHERE Clause

    This parameter is displayed when Clear Data Before Import is set to Clear all data.

    Used to specify the data to be deleted from the target table before data import, for example, age > 18 and age <= 60

    Extend Field Length

    Advanced attribute parameter.

    When a destination table is automatically created, the length of the character fields can be extended to three times the original length. If the encoding types of the source and destination databases are different, but the character fields in the source and destination tables are the same, errors may occur during data migration due to character length difference.

    Use NOT NULL Constraint

    Advanced attribute parameter.

    If you choose to create a target table automatically and specify the NOT NULL constraint, keep the NOT NULL constraints of the source and target tables consistent.

    CSS

    Index

    Index to which data is written. If multiple indexes are migrated at a time, this parameter cannot be configured. CDM automatically creates indexes at the migration destination.

    Clear Data Before Import

    Whether to clear data of the target type before data is written

    DWS

    N/A

    For details about the destination job parameters required for entire DB migration to DWS, see Destination Relational Database Parameters.

    OBS

    N/A

    For details about the destination job parameters required for entire DB migration to OBS, see Destination OBS Parameters.

  5. If a relational database is migrated, after job parameters are configured, click Next to access the page for selecting tables. You can select the tables to be migrated to the migration destination based on your requirements.
  6. Click Next, set job parameters, and click Show Advanced Attributes to display and configure optional parameters.
    Figure 3 Task parameters 1
    Table 4 describes related parameters.
    Table 4 Parameter description

    Parameter

    Description

    Example Value

    Retry upon Failure

    You can select Retry 3 times or Never.

    You are advised to configure automatic retry for only file migration jobs or database migration jobs with Import to Staging Table enabled to avoid data inconsistency caused by repeated data writes.

    Never

    Job

    Select a group where the job resides. The default group is DEFAULT. On the Job Management page, jobs can be displayed, started, or exported by group.

    DEFAULT

    Schedule Execution

    If you select Yes, you can set the start time, cycle, and validity period of a job. For details, see Scheduling Job Execution.

    No

    Concurrent Extractors

    Number of extractors to be concurrently executed. Generally, retain the default value.

    1

    Concurrent Loaders

    Number of Loaders to be concurrently executed

    This parameter is displayed only when HBase or Hive serves as the destination data source.

    3

    Write Dirty Data

    Whether to record dirty data. By default, this parameter is set to No.

    Yes

    Write Dirty Data Link

    This parameter is displayed only when Write Dirty Data is set to Yes.

    Only links to OBS support dirty data writes.

    obs_link

    OBS Bucket

    This parameter is displayed only when Write Dirty Data Link is a link to OBS.

    Name of the OBS bucket to which the dirty data is to be written.

    dirtydata

    Dirty Data Directory

    This parameter is displayed only when Write Dirty Data is set to Yes.

    Dirty data is stored in the directory for storing dirty data on OBS. Dirty data is saved only when this parameter is configured.

    You can go to this directory to query data that fails to be processed or is filtered out during job execution, and check the source data that does not meet conversion or cleaning rules.

    /user/dirtydir

    Max. Error Records in a Single Shard

    This parameter is displayed only when Write Dirty Data is set to Yes.

    When the number of error records of a single map exceeds the upper limit, the job will automatically terminate and the imported data cannot be rolled back. You are advised to use a temporary table as the destination table. After the data is imported, rename the table or combine it into the final data table.

    0

    Delete Job After Completion

    Perform the following operations after a job is executed:
    • Do not delete: The job is not deleted after it is executed.
    • Delete after success: The job is deleted only when the job is successfully executed. It is applicable to massive one-time jobs.
    • Delete: The job is deleted regardless of whether it is successfully executed or fails to be executed.

    Do not delete

  7. Click Save or Save and Run.

    When the job starts running, a sub-job will be generated for each table. You can click the job name to view the sub-job list.