Migrate a self-managed PostgreSQL database to AnalyticDB for MySQL 3.0
This topic describes how to use Data Transmission Service (DTS) to migrate data from a self-managed PostgreSQL database to an AnalyticDB for MySQL AnalyticDB for MySQL3.0 cluster. DTS supports schema migration, full data migration, and incremental data migration, so you can continue to receive source changes while historical data is migrated.
Prerequisites
A self-managed PostgreSQL source database is deployed, and a destination AnalyticDB for MySQL AnalyticDB for MySQL3.0 cluster is created.
For information about the supported versions of the source and destination databases, see Overview of migration scenarios.
The destination AnalyticDB for MySQL cluster has enough space for the data to be migrated and for the additional storage consumed during writes. For instructions, see Create a cluster.Create a cluster
Network connectivity and account authorization from the source and destination databases to DTS are complete. For configuration instructions, see Preparations.
The primary keys, data types, and value ranges of the tables to be migrated are verified against Migration scope and limits, and objects that do not meet those limits are handled in advance.
If incremental data migration is included, logical replication is enabled on the source database, and WAL logs are prepared to cover the full data migration phase, failure retries, and incremental catch-up.
Migration scope and limits
DTS migrates foreign keys during schema migration.
During full and incremental data migration, DTS temporarily disables constraint checks and foreign key cascades at the session level. Cascade updates or deletes on the source database while the task runs may cause data inconsistency.
DTS does not support performing a full migration in multiple stages; the full migration must be completed in a single operation. If you need to migrate data in batches, please configure multiple migration tasks.
This scenario migrates data between heterogeneous databases. DTS migrates table schemas and data. The destination database does not recreate PostgreSQL sequences, functions, triggers, views, materialized views, custom type objects, regular indexes, unique indexes, foreign keys, or CHECK constraints. Converting a custom-type column to a string does not mean that the corresponding type object or its operation rules are also migrated.
Type | Description |
Source database limits | Tables with generated columns in PostgreSQL 18 do not support migration. If you configure migration for such tables, DML operations on those tables will be blocked.
|
Other limits |
|
| Type | Description |
| Source database limitation | A single task can migrate only one PostgreSQL database. Configure a separate task for each additional database. |
| Source database limitation | The tables to be migrated must have a primary key, and all primary key columns must be included in the migration objects. When a table is created during the incremental phase, CREATE TABLE must define a primary key. CREATE TABLE statements without a primary key are skipped. A UNIQUE constraint alone does not meet this requirement. |
| Source database limitation | If incremental data migration is included, enable logical replication. wal_level, max_wal_senders, max_replication_slots, and the number of replication slots must meet the check requirements described in Preparations. |
| Source database limitation | The WAL log retention period must meet the requirements of the decision table in Migration types. Long-running transactions and consumption delays can cause WAL files to accumulate. Monitor the disk space of the source database. For more source database requirements, see Precautions and limits for PostgreSQL source databases. |
| Source database limitation | Do not run DDL operations on the migration objects during schema migration or full data migration. Do not perform a major engine version upgrade while the task is running. Do not treat a primary/secondary switchover of a self-managed PostgreSQL database as a scenario that can automatically resume transmission. |
| Source database limitation | Incremental DDL support is limited to the operations listed in SQL operations supported for incremental data migration. DDL operations outside that scope are not automatically converted. Regular one-dimensional array columns can be migrated as strings. |
| Source database limitation | MONEY columns carry a risk of data read failures. Their schema can be mapped to DECIMAL(19,2), but some data read scenarios fail. Organize the data to be migrated into verified NUMERIC columns before you configure the task. |
| Destination database limitation | Destination tables must have a custom primary key that uniquely identifies source records. When you create destination tables in advance, make sure that the primary key matches the source table and includes the distribution key and partition key required by the destination table. Do not rely on a primary key automatically generated by the destination database to associate source records. |
| Destination database limitation | PostgreSQL geometric types and arrays are stored as VARCHAR. They cannot be migrated directly to native AnalyticDB for MySQL POINT or ARRAY types. AnalyticDB for MySQL 3.0 supports these types, but that does not mean this link supports the corresponding native type conversion. |
| Destination database limitation | Values must fall within the value range of the destination column. Automatic schema conversion cannot be relied on for NUMERIC with a negative scale, a scale greater than the precision, or a definition that exceeds the destination DECIMAL precision limit. For NUMERIC without a specified precision, confirm the destination precision and the actual value range first. |
| Other limitations | The character sets of the source and destination databases must be compatible. Time values are written in the configured destination time zone. The original time zone name or offset is not retained as a separate attribute. Time precision is handled at millisecond level at most, and the microsecond and nanosecond parts may be truncated. |
| Other limitations | Sequence values, identity column values, time values, and UUID values are taken from the data already generated on the source. Do not configure dynamic default values or auto-generation expressions on destination tables to fill in values, and do not use the current time of the destination database in place of source values. |
| Other limitations | For tables with dynamic default values, verify the destination CREATE TABLE definition before you start data migration. If the automatically generated definition still contains dynamic expressions such as CURRENT_TIMESTAMP, create the destination tables without those expressions in advance and disable schema migration. Remove dynamic default values even when the destination column already has explicitly written values. |
| Other limitations | When tables are created, columns are added, or column types are changed during incremental migration, the DEFAULT, regular NOT NULL, and auto-generation attributes of the source columns are not retained. The primary key requirements must still be met. Existing destination rows are not automatically backfilled with source default values. |
| Other limitations | Both full and incremental writes can overwrite records with the same primary key in the destination table. Use a dedicated destination table. Other applications must not write to the same destination table while the task is running. |
| Other limitations | Some DDL operations that cannot be parsed or are unsupported trigger alerts and are skipped. A task that continues to run does not mean that the table schemas remain consistent. Use the task logs to verify the destination table schemas. |
Billing
|
Migration type |
Instance configuration fee |
Internet traffic fee |
|
Schema migration and full data migration |
Free of charge. |
When the Access Method parameter of the destination database is set to Public IP Address, you are charged for Internet traffic. For more information, see Billing overview. |
|
Incremental data migration |
Charged. For more information, see Billing overview. |
For tables with generated columns, a successfully converted CREATE TABLE statement does not prove that the data migrates correctly. Generation expressions are not retained in the destination. First confirm that the source can output the required column values and that full and incremental results are consistent. Do not include such tables before this verification is complete.
Migration types
-
Schema migration
DTS migrates the schema definitions of the migration objects from the source database to the destination database.
-
Full migration
DTS migrates all historical data of the specified migration objects from the source database to the destination database.
-
Incremental migration
After a full migration is complete, DTS migrates incremental data updates from the source database to the destination database. Incremental migration lets you smoothly migrate data without interrupting your self-managed applications.
| Migration type | Description |
| Schema migration | Creates compatible table schemas in the destination database and converts column types and primary keys according to the rules for this scenario. Not all source database objects and constraints are guaranteed to be retained. |
| Full data migration | Reads historical records from the tables to be migrated and writes them to the destination tables. |
| Incremental data migration | Continuously reads data changes from source WAL logs and writes them to the destination database. For the supported DDL scope, see SQL operations supported for incremental data migration. |
Select a migration type combination from the following table based on your write suspension window and costs:
| Scenario | Migration type combination | Write suspension requirement | WAL log retention | Link configuration fees |
| Migrate historical data only | Schema migration and full data migration | Stop writes to source tables during migration | Not applicable | No link configuration fees are charged |
| Migrate historical data while continuously receiving source changes | Schema migration, full data migration, and incremental data migration | Source tables can continue to accept writes during migration. Stop writes and validate the data before the final switchover. | Retain for at least 7 days when full and incremental data migration run together. After the full data migration phase is complete, you can reduce this to at least 24 hours. Retain for at least 24 hours when only incremental data migration runs. | Incremental data migration is charged. For the billing rules, see Billing overview. No link configuration fees are charged for schema migration or full data migration. |
Billing
For the link configuration fees of each migration type combination, see the decision table in Migration types. The source database, the destination database, and the related network resources are charged according to the rules of the corresponding products. If Internet traffic is involved, also check the DTS traffic billing conditions.
Preparations
Prepare database accounts based on the phases that the task requires.
Database Permission requirements Self-managed PostgreSQL For schema migration and full data migration only, the account must have metadata access and read permissions on the tables to be migrated. If incremental data migration is included, prepare an account with superuser permissions according to the requirements for a self-managed PostgreSQL source database. AnalyticDB for MySQLAnalyticDB for MySQL AnalyticDB for MySQL3.0 Read and write permissions on the destination database. If schema processing or incremental DDL is included, the account must also be able to run the corresponding CREATE TABLE, ALTER TABLE, and DROP TABLE operations. For account requirements, see Prepare database accounts for data migration or Prepare database accounts for data synchronization.Create a database account
Prerequisites
NoteIf your source database is an Amazon RDS for PostgreSQL instance, see Prerequisites. If your source database is an Amazon Aurora PostgreSQL instance, see Preparation 1: Adjust the inbound rules of the Amazon Aurora PostgreSQL instance.
The following steps are for Linux.
Follow these steps for all versions of self-managed PostgreSQL.
Log in to the server hosting your self-managed PostgreSQL database.
Run the following command to query the number of used replication slots in the database.
select count(1) from pg_replication_slots;Modify the
postgresql.confconfiguration file. Set thewal_levelparameter tological, and ensure that themax_wal_sendersandmax_replication_slotsparameters are greater than the number of used replication slots plus the number of DTS instances that you plan to create.# - Settings - wal_level = logical # minimal, replica, or logical # (change requires restart) ...... # - Sending Server(s) - # Set these on the master and on any standby that will send replication data. max_wal_senders = 10 # max number of walsender processes # (change requires restart) #wal_keep_segments = 0 # in logfile segments, 16MB each; 0 disables #wal_sender_timeout = 60s # in milliseconds; 0 disables max_replication_slots = 10 # max number of replication slots # (change requires restart)NoteAfter you modify the configuration file, you must restart the self-managed PostgreSQL database to apply the changes.
Add the CIDR blocks of DTS servers to the pg_hba.conf configuration file of your self-managed PostgreSQL database. You only need to add the CIDR blocks for the DTS servers in the region where your destination database is located. For more information, see Add the CIDR blocks of DTS servers to a whitelist.
NoteAfter you modify the configuration file, run the
SELECT pg_reload_conf();command or restart the self-managed PostgreSQL database to apply the changes.For more information about the settings in this configuration file, see The pg_hba.conf File. If you have already set the trusted address to
0.0.0.0/0(as shown in the following example), you can skip this step.
In the
pg_hba.conffile, set the addresses for IPv4 connections and replication connections to0.0.0.0/0and the authentication method tomd5. Sample configuration:# "local" is for Unix domain socket connections only local all all trust # IPv4 local connections: host all all 0.0.0.0/0 md5 # IPv6 local connections: host all all ::1/128 trust # Allow replication connections from localhost, by a user with the # replication privilege. local replication postgres trust host replication postgres 0.0.0.0/0 md5In the destination database instance, create databases and schemas that correspond to the source objects you are migrating.
For self-managed PostgreSQL versions 9.4.8 to 10.0, follow these additional steps.
Download, compile, and install the PostgreSQL source code.
Download the source code for your self-managed PostgreSQL version from the PostgreSQL official website.
Run the
sudo ./configure,sudo make, andsudo make installcommands in sequence to configure, compile, and install the source code.ImportantWhen you compile and install PostgreSQL, the operating system version must be compatible with the GNU Compiler Collection (GCC) version.
If an error occurs when you run the
sudo ./configurecommand, you can modify the command based on the error message. For example, if the error message isreadline library not found. Use --without-readline to disable readline support., change the command tosudo ./configure --without-readline.If you install PostgreSQL by using another method, you must compile the ali_decoding plugin in a test environment that uses the same operating system and GCC versions as your production environment.
Download, compile, and install the ali_decoding plugin provided by DTS.
Download ali_decoding.
Copy the entire ali_decoding directory to the
contribdirectory of your PostgreSQL installation.total 1008 -rw-r--r-- 1 1107 1107 384 Sep 27 2016 aclocal.m4 drwxrwxrwx 2 1107 1107 4096 Sep 27 2016 config -rw-r--r-- 1 root root 374806 Sep 7 10:10 config.log -rwxr-xr-x 1 root root 39032 Sep 7 10:10 config.status -rwxr-xr-x 1 1107 1107 471157 Sep 27 2016 configure -rw-r--r-- 1 1107 1107 75195 Sep 27 2016 configure.in drwxrwxrwx 56 1107 1107 4096 Sep 7 10:28 contrib -rw-r--r-- 1 1107 1107 1192 Sep 27 2016 COPYRIGHT drwxrwxrwx 3 1107 1107 4096 Sep 27 2016 doc -rw-r--r-- 1 root root 3638 Sep 7 10:10 GNUmakefile -rw-r--r-- 1 1107 1107 3638 Sep 27 2016 GNUmakefile.in -rw-r--r-- 1 1107 1107 283 Sep 27 2016 HISTORY -rw-r--r-- 1 1107 1107 75065 Sep 27 2016 INSTALL -rw-r--r-- 1 1107 1107 1489 Sep 27 2016 Makefile -rw-r--r-- 1 1107 1107 1209 Sep 27 2016 README drwxrwxrwx 16 1107 1107 4096 Sep 7 10:10 srcGo to the ali_decoding directory and replace the contents of the
Makefilefile with the following code:# contrib/ali_decoding/Makefile MODULE_big = ali_decoding MODULES = ali_decoding OBJS = ali_decoding.o DATA = ali_decoding--0.0.1.sql ali_decoding--unpackaged--0.0.1.sql EXTENSION = ali_decoding NAME = ali_decoding #subdir = contrib/ali_decoding #top_builddir = ../.. #include $(top_builddir)/src/Makefile.global #include $(top_srcdir)/contrib/contrib-global.mk #PG_CONFIG = /usr/pgsql-9.6/bin/pg_config #pgsql_lib_dir := $(shell $(PG_CONFIG) --libdir) #PGXS := $(shell $(PG_CONFIG) --pgxs) #include $(PGXS) # Use the following for source code installation ifdef USE_PGXS PG_CONFIG = pg_config PGXS := $(shell $(PG_CONFIG) --pgxs) include $(PGXS) else subdir = contrib/ali_decoding top_builddir = ../.. include $(top_builddir)/src/Makefile.global include $(top_srcdir)/contrib/contrib-global.mk endifGo to the ali_decoding directory. Run the
sudo makeandsudo make installcommands in sequence to compile the ali_decoding plugin and generate the required installation files.Copy the following files to the specified locations.
/usr/bin/install -c -m 755 ali_decoding.so '/usr/local/pgsql/lib/ali_decoding.so' /usr/bin/install -c -m 644 ./ali_decoding.control '/usr/local/pgsql/share/extension/' /usr/bin/install -c -m 644 ./ali_decoding--0.0.1.sql ./ali_decoding--unpackaged--0.0.1.sql '/usr/local/pgsql/share/extension/' /usr/bin/install -c -m 755 ali_decoding.so '/usr/local/pgsql/lib/'
In the destination database instance, create databases and schemas that correspond to the source objects you are migrating.
If incremental data migration is included, configure logical replication on the source database and run the following queries to check whether the parameters have taken effect.
SHOW wal_level; SHOW max_wal_senders; SHOW max_replication_slots; SELECT count(*) FROM pg_replication_slots;wal_levelmust returnlogical.
Configure the logical decoding component according to the source database version. Earlier versions require the additional installation ofmax_wal_sendersandmax_replication_slotsmust both be greater than the sum of the number of replication slots in use (the count returned bypg_replication_slots) and the number of DTS instances that you plan to create.ali_decoding. For configuration instructions, see Prepare a self-managed PostgreSQL source database. For parameters that take effect only after a restart, check them again after you restart the database during a maintenance window.
Configure the network access control of the source database and
pg_hba.confto allow database and replication connections from DTS servers in the applicable region. For the specific CIDR blocks, see Add the CIDR blocks of DTS servers to the security settings of on-premises databases.If incremental data migration is included, set full replica identity for the tables to be migrated before the first run, before you add migration objects, or before you include a new table in the migration.
ALTER TABLE schema_name.table_name REPLICA IDENTITY FULL;NoteReplace
schema_nameandtable_namewith the actual names, and run the statement during off-peak hours. This setting does not replace a primary key. If DDL operations must be migrated, also retain the DDL collection objects, heartbeat tables, and replication slots that DTS creates. Do not delete these objects while the task is running.Verify the destination primary keys, data types, time zones, and default values. For tables that require a custom destination schema, create the tables in the destination database in advance and make sure that the columns can fully receive the source records.
Procedure
This procedure uses a self-managed PostgreSQL database on an Alibaba Cloud ECS instance as the source and AnalyticDB for MySQL 3.0 as the destination, and describes how to configure a one-way migration.
-
Navigate to the migration task list page for the destination region using one of the following methods.
From the DTS console
-
Log on to the Data Transmission Service (DTS) console.
-
In the navigation pane on the left, click Data Migration.
-
In the upper-left corner of the page, select the region where the migration instance is located.
From the DMS console
NoteThe actual operations may vary based on the mode and layout of the DMS console. For more information, see Simple mode console and Customize the layout and style of the DMS console.
-
Log on to the Data Management (DMS) console.
-
In the top menu bar, choose .
-
To the right of Data Migration Tasks, select the region where the migration instance is located.
-
-
Click Create Task to navigate to the task configuration page.
Open the data migration task list in the destination region.
Open it from the DTS console: Log on to the Data Transmission Service (DTS) console, in the left-side navigation pane, choose Data Migration, and switch to the region where the task resides.
Open it from the DMS console: Log on to the DMS console. From the top menu, choose Data + AI > Data Transmission (DTS) > Data Migration, and then select the region of the task.
Click Create Task.
Configure the source and destination database information.
WarningBefore you configure the task, check Data type mappings and SQL operations supported for incremental data migration. The source database accepting a SQL operation does not mean that the destination can preserve the same semantics.
Category Parameter Description Configure the source and destination databases.
| Basic information | Task Name |DTS automatically generates a task name. We recommend that you specify a descriptive name for easy identification. The name does not need to be unique.
Enter a name that identifies the workload and the migration direction. | | Source Database | Select Existing Connection | If a connection is already saved, select it directly. Otherwise, enter the following information manually. | | Source database information | Database Type | Select PostgreSQL. | | Source database information | Access Method | Select based on how the source database is deployed. In this example, the source database is deployed on an ECS instance, so select Self-managed Database on ECS. For other deployment methods, select based on the actual network. Before you configure the task, complete the applicable steps in Preparations, including the network access permissions.Preparations Overview | | Source database information | Instance Region | Select the region where the source database is located. | | Source database information | ECS Instance ID | Select the ECS instance that runs the source database. | | Source database information | Port Number | Enter the actual service port. The default PostgreSQL port is 5432. | | Source database information | Database Name | Enter the name of the PostgreSQL database that contains the objects to be migrated. | | Source database information | Encryption |-
To use a database instance that has been added to the system (created or saved), select the desired database instance from the drop-down list. The database information below will be automatically configured.
NoteIn the DMS console, this parameter is named Select a DMS database instance..
-
If you have not registered the database instance with the system, or do not need to use a registered instance, manually configure the database information below.
Select based on whether SSL encryption is enabled for the source database. If it is not enabled, select a non-encrypted connection. If it is enabled, select an SSL-encrypted connection and upload the CA certificate, the client certificate, and other materials as the interface requires. | | Source database information | Database Account and Database Password |Specifies whether to encrypt the connection to the source database. You can configure this parameter based on your business requirements. In this example, Non-encrypted is selected.
If you want to establish an SSL-encrypted connection to the source database, perform the following steps: Select SSL-encrypted, upload CA Certificate, Client Certificate, and Private Key of Client Certificate as needed, and then specify Private Key Password of Client Certificate.
Note-
If you set Encryption to SSL-encrypted for a self-managed PostgreSQL database, you must upload CA Certificate.
-
If you want to use the client certificate, you must upload Client Certificate and Private Key of Client Certificate and specify Private Key Password of Client Certificate.
-
For information about how to configure SSL encryption for an ApsaraDB RDS for PostgreSQL instance, see SSL encryption.
Enter the password for the database account.
Enter the source database account and password that you authorized in Preparations.Migrate data from a self-managed PostgreSQL database to AnalyticDB for PostgreSQL | | Destination Database | Select Existing Connection | If a connection is already saved, select it directly. Otherwise, enter the following information manually. | | Destination database information | Database Type | Select AnalyticDB for MySQL 3.0. | | Destination database information | Access Method | Select Alibaba Cloud Instance. | | Destination database information | Instance Region | Select the region of the destination cluster. | | Destination database information | Instance ID | Select the destination cluster that receives the data. | | Destination database information | Database Name | Enter the name of the database in the destination instance that contains the migration objects. | | Destination database information | Database Account and Database Password |-
To use a database instance that has been added to the system (created or saved), select the desired database instance from the drop-down list. The database information below will be automatically configured.
NoteIn the DMS console, this parameter is named Select a DMS database instance..
-
If you have not registered the database instance with the system, or do not need to use a registered instance, manually configure the database information below.
Enter the password for the database account.
Enter the account and password that have read and write permissions on the destination database and the required DDL permissions.Migrate data from a self-managed PostgreSQL database to AnalyticDB for PostgreSQL |-
After completing the configuration, click Test Connectivity and Proceed at the bottom of the page.
NoteEnsure that you add the CIDR blocks of the DTS servers (either automatically or manually) to the security settings of both the source and destination databases to allow access. For more information, see Add the IP address whitelist of DTS servers.
If the source or destination is a self-managed database (i.e., the Access Method is not Alibaba Cloud Instance), you must also click Test Connectivity in the CIDR Blocks of DTS Servers dialog box.
Click Test Connection and Go to Next Step. If the Authorize DTS Server Access dialog box appears, verify the network authorization for the source and destination databases, and then click Test Connection.
Configure the task objects.
a. On the Object Configuration page, configure the following parameters.
Configure the task objects.
Parameter Description Migration Types Based on the decision table in Migration types, select Schema Migration, Full Data Migration, and Incremental Data Migration. If the destination tables are already created as required, do not select schema migration.-
If you only need to perform a full migration, select both Schema Migration and Full Data Migration.
-
To perform a migration with no downtime, select Schema Migration, Full Data Migration, and Incremental Data Migration.
Note-
If you do not select Schema Migration, you must ensure that a database and tables to receive the data exist in the destination database. You can also use the object name mapping feature in the Selected Objects box as needed.
-
If you do not select Incremental Data Migration, do not write new data to the source instance during data migration to ensure data consistency.
Processing Mode of Conflicting Tables -
Precheck and Report Errors: Checks whether tables with the same names exist in the destination database. If no tables with the same names exist, the precheck is passed. If tables with the same names exist, an error is reported during the precheck, and the data migration task does not start.
NoteIf a table in the destination database has the same name but cannot be easily deleted or renamed, you can change the name of the table in the destination database. For more information, see Object name mapping.
-
Ignore Errors and Proceed: Skips the check for tables with the same names.
WarningSelecting Ignore Errors and Proceed may cause data inconsistency and business risks. For example:
-
If the table schemas are consistent and a record in the destination database has the same primary key value as a record in the source database:
-
During full migration, DTS keeps the record in the destination database. The record from the source database is not migrated.
-
During incremental migration, DTS does not keep the record in the destination database. The record from the source database overwrites the record in the destination database.
-
-
If the table schemas are inconsistent, only some columns of data may be migrated, or the migration may fail. Proceed with caution.
-
Source Objects In the Source Objects box, click the objects to migrate, and then click
to move them to the Selected Objects box.Select the regular tables to be migrated and move them to Selected Objects. When you select by database or by schema, also exclude the unsupported objects.NoteThe granularity for selecting migration objects is schema, table, and column. If you select only tables or columns as migration objects, other objects such as views, triggers, and stored procedures are not migrated to the destination database.
Selected Objects -
To change the name of a single migration object in the target instance, right-click the object in the Selected Objects box. For more information, see Map individual schema, table, and column names.
-
To change the names of multiple migration objects in the target instance, click Selected Objects in the upper-right corner of the Batch Edit box. For more information, see Map multiple schema, table, and column names.
You can configure the case sensitivity policy for the names of migrated objects, such as databases, tables, and columns, in the destination instance. By default, DTS default policy is selected. You can also choose to keep the case sensitivity consistent with the default policy of the source or destination database. For more information, see Case sensitivity of object names in the destination database.
Capitalization of Object Names in Destination Instance applies to object name mapping. Do not exclude primary key columns. For instructions, see Map database, table, and column names and Set filter conditions.Filter task data with an SQL conditionDDL and DML Operations to Be Synchronized Select only the SQL operations that this topic supports. To receive newly created tables, the new tables must fall within the Selected Objects scope. Do not select only CREATE TABLE without configuring the corresponding object scope.Migrate data from a self-managed PostgreSQL database to AnalyticDB for PostgreSQL WarningIgnore Errors and Continue skips only the same-name table check. It does not preserve existing destination records. Both full and incremental writes on this link can replace records that share the same primary key, and inconsistent schemas can also cause write failures. Back up the destination data that must be retained first.
b.
Configure the task objects.
Click Next: Advanced Settings to configure advanced parameters.
Click Next: Advanced Settings, and configure the advanced parameters based on your business requirements.Parameter Description Dedicated Cluster for Task Scheduling By default, DTS schedules tasks on a shared cluster. You do not need to select one. If you want more stable tasks, you can purchase a dedicated cluster to run DTS migration tasks.
No selection is required when you use a shared cluster. If you have purchased a dedicated cluster, you can select that cluster.Retry Time for Failed Connections Set the connection retry window based on your fault recovery objectives, and make sure that the source logs cover the time required for retries and catch-up.After the migration task starts, if the connection to the source or destination database fails, DTS reports an error and immediately begins to retry the connection. The default retry duration is 720 minutes. You can customize the retry time to a value from 10 to 1440 minutes. We recommend that you set the duration to more than 30 minutes. If DTS reconnects to the source and destination databases within the specified duration, the migration task automatically resumes. Otherwise, the task fails.
Note-
For multiple DTS instances that share the same source or destination, the network retry time is determined by the setting of the last created task.
-
Because you are charged for the task during the connection retry period, we recommend that you customize the retry time based on your business needs, or release the DTS instance as soon as possible after the source and destination database instances are released.
Retry Time for Other Issues Configure the retry window for non-connection errors. It must be shorter than the connection retry window. Do not rely on retries to make up for DDL operations that were filtered out.After the migration task starts, if a non-connectivity issue, such as a DDL or DML execution exception, occurs in the source or destination database, DTS reports an error and immediately begins to retry the operation. The default retry duration is 10 minutes. You can customize the retry time to a value from 1 to 1440 minutes. We recommend that you set the duration to more than 10 minutes. If the related operations succeed within the specified retry duration, the migration task automatically resumes. Otherwise, the task fails.
ImportantThe value of Retry Time for Other Issues must be less than the value of Retry Time for Failed Connections.
Enable Throttling for Full Data Migration When full data migration is required, set QPS, RPS, and BPS based on the source database read load and the destination write capacity.During full migration, DTS consumes read and write resources on the source and destination databases, which may increase the database load. If required, you can enable throttling for the full migration task. You can set Queries per second (QPS) to the source database, RPS of Full Data Migration, and Data migration speed for full migration (MB/s) to reduce the load on the destination database.
Note-
This configuration item is available only if you select Full Data Migration for Migration Types.
-
You can also adjust the full migration speed after the migration instance is running.
Enable Throttling for Incremental Data Migration Set throttling based on the actual write capacity to prevent sustained throttling from causing log accumulation.If required, you can also choose to set speed limits for the incremental migration task. You can set RPS of Incremental Data Migration and Data migration speed for incremental migration (MB/s) to reduce the load on the destination database.
Note-
This configuration item is available only if you select Incremental Data Migration for Migration Types.
-
You can also adjust the incremental migration speed after the migration instance is running.
Environment Tag Configure based on your business requirements. Configure ETL In this example, select No.Choose whether to enable the extract, transform, and load (ETL) feature. For more information, see What is ETL? Valid values:
-
Yes: Enables the ETL feature. Enter data processing statements in the code editor. For more information, see Configure ETL in a data migration or data synchronization task.
-
No: Disables the ETL feature.
Monitoring and Alerting (Recommended) Configure task failure and latency alerts, and enter the alert contacts.Select whether to set alerts and receive alert notifications based on your business needs.
-
No: Does not set an alert.
-
Yes: Configure alerts by setting an alert threshold and an alert contact. If a migration fails or the latency exceeds the threshold, the system sends an alert notification.
c. If Migration Types includes Schema Migration, on the Next: Configure Database and Table Fields page, verify the destination column types, primary key columns, distribution keys, and partition information. The primary key and distribution rules must meet the CREATE TABLE requirements.Manage tablesDefine table distributionTasks that use pre-created destination tables must complete the same verification before they start.
d. Go to Next: Data Verification. If verification configuration is available for the current link, create a verification task as needed. Whether or not automatic verification is enabled, verify the key fields, primary keys, row counts, and data precision for type conversions.
-
-
Click Next: Data Validation to configure a data validation task.
For more information about the data validation feature, see Configure data validation.
Click Next: Save Task and Precheck.
If a check fails, click View Details for the item, fix the permission, connection, object, or schema problem, and then run the check again.
For warning items, confirm the impact before you decide whether to ignore them. Do not ignore alerts and continue running for problems such as missing primary keys, incompatible data types, or logs that do not meet the requirements.
A successful precheck does not mean that all actual data boundaries and business DDL operations have been verified.
-
Save the task and run a precheck.
-
To view the parameters for configuring this instance when you call the API operation, move the pointer over the Next: Save Task Settings and Precheck button and click Preview OpenAPI parameters in the bubble that appears.
-
If you do not need to view or have finished viewing the API parameters, click Next: Save Task Settings and Precheck at the bottom of the page.
Note-
Before the migration task starts, DTS performs a precheck. The task starts only after it passes the precheck.
-
If the precheck fails, click View Details next to the failed check item, fix the issue based on the prompt, and then run the precheck again.
-
If a warning is reported during the precheck:
-
For check items that cannot be ignored, click View Details next to the failed item, fix the issue based on the prompt, and then run the precheck again.
-
For check items that can be ignored, you can click Confirm Alert Details, Ignore, OK, and Precheck Again to skip the alert item and run the precheck again. If you choose to ignore a warning, it may cause issues such as data inconsistency and pose risks to your business.
-
-
-
When the Success Rate is 100%, click Next: Purchase Instance.
-
On the Purchase page, select the link specification for the data migration instance. For more information, see the following table.
Category
Parameter
Description
New Instance Class
Resource Group Settings
Select the resource group to which the instance belongs. The default value is default resource group. For more information, see What is Resource Management?
Instance Class
DTS provides migration specifications with different performance levels. The link specification affects the migration speed. You can select a specification based on your business scenario. For more information, see Data migration link specifications.
-
After the configuration is complete, read and select Data Transmission Service (Pay-as-you-go) Service Terms.
-
Click Buy and Start. In the OK dialog box that appears, click OK.
You can view the progress of the migration task on the Data Migration Tasks list page.
Note-
If the migration task does not include incremental migration, it stops automatically after the full migration is complete. After the task stops, its Status changes to Completed.
-
If the migration task includes incremental migration, it does not stop automatically. The incremental migration task continues to run. While the incremental migration task is running, the Status of the task is Running.
-
AnalyticDB for MySQLAfter the precheck is successful, click Next: Purchase, and configure the resource group and the link specifications. After you verify the order and the terms of service, click Purchase and Start, and then click OK in the confirmation dialog box.
After the task starts, view the phase progress in the data migration list, and use the task logs to verify the schema processing and data write results. After both the schema migration and full data migration phases are complete, the historical data is in place. Some DDL operations that cannot be parsed or are unsupported trigger alerts and are skipped. A task that continues to run does not mean that the table schemas remain consistent, so you must confirm the destination table schemas by using the task logs. If incremental data migration is included, the task keeps running. Stop the source writes, wait for committed changes to catch up, and complete data validation before you switch writes to the destination.
What's next
After full data migration is complete, verify the destination primary keys, table schemas, row counts, and key fields. Focus on precision, time zones, NULL values, binary data, and string-converted types.
If incremental data migration is included, the task keeps running. To switch over your workload, first stop the source writes, wait for committed changes to catch up, and then run data validation.
After validation confirms consistency, end or release the migration task before you switch writes to the destination. This prevents the task from overwriting new destination data if it resumes. Do not switch writes to the destination if validation finds inconsistencies.
Tasks that include only schema migration and full data migration can be ended after those phases are complete. Ending a task does not mean that application SQL, stored procedures, indexes, and business constraints have been refactored.
SQL operations supported for incremental data migration
| Operation type | SQL statements |
| DML | INSERT, UPDATE, and DELETE |
| DDL | CREATE TABLE; ADD COLUMN, DROP COLUMN, RENAME COLUMN, RENAME TO, and ALTER COLUMN ... TYPE for ALTER TABLE; DROP TABLE; and TRUNCATE TABLE.
|
New tables must be included in the migration object scope, and CREATE TABLE must include a primary key. The automatically generated destination distribution key uses the primary key columns.
ALTER COLUMN ... TYPE applies only to type changes that the destination database allows. USING expressions are not supported as data conversion or historical data recalculation operations.
Changes to indexes, sequences, views, functions, triggers, COMMENT, and constraints are not supported. Incremental DDL that contains multi-dimensional array definitions, PARTITION BY, table inheritance, or cascading foreign key definitions is not supported. DROP TABLE with CASCADE is not supported.
Newly added columns are not automatically backfilled for existing destination rows based on source default values. Tasks that include incremental DDL require separate validation of existing data and of data changed afterwards.
DTS may generate auxiliary indexes for destination columns that support indexes. This does not mean that CREATE INDEX statements, index definitions, or UNIQUE constraints from the source database are migrated.
A single source DDL operation may be split into multiple destination statements. If an error occurs, the earlier statements may already have taken effect, so verify the complete result.
Write semantics: Incremental INSERT and regular UPDATE operations are written to the destination as REPLACE INTO. When a primary key is updated, the record with the old primary key is deleted first, and then the new record is written. Make sure that the primary key and the row information before and after the update are complete.
Data type mappings
The following table lists the main type mappings for this link. A string mapping preserves the text representation of the data. It does not preserve the constraints, indexes, operators, or computational capabilities of the source type.
| PostgreSQL type | AnalyticDB for MySQL 3.0 type | Description |
| SMALLINT, INT2, and SMALLSERIAL | SMALLINT | SMALLSERIAL migrates only the integer values generated on the source. |
| INTEGER, INT, INT4, and SERIAL | INT | SERIAL is not converted into an auto-increment generation mechanism in the destination. |
| BIGINT, INT8, and BIGSERIAL | BIGINT | The destination integer value range must cover the source data. |
| DECIMAL(p,s) and NUMERIC(p,s) | DECIMAL(p,s) | Applies only to the precision and scale values that the destination supports. |
| NUMERIC and DECIMAL (precision not specified) | DECIMAL | Verify the default destination precision and the source value range. |
| MONEY | DECIMAL(19,2) | A schema mapping exists, but some data read scenarios fail. This does not mean that full and incremental data migration always complete as expected. Organize the data to be migrated into verified NUMERIC columns before you configure the task. |
| REAL and FLOAT4 | FLOAT | Floating-point values may differ because of approximate representation. |
| DOUBLE PRECISION and FLOAT8 | DOUBLE | Floating-point values may differ because of approximate representation. |
| BOOLEAN and BOOL | BOOLEAN | true and false map to 1 and 0. |
| CHAR, CHARACTER, BPCHAR, VARCHAR, CHARACTER VARYING, and TEXT | VARCHAR | Fixed-length padding and length validation semantics from the source are not retained. |
| BYTEA | VARBINARY | Binary data. The destination database may display it as a BINARY type. |
| DATE | DATE | Source values must fall within the destination date range. |
| TIME and TIME WITHOUT TIME ZONE | TIME | Time precision beyond the range supported by the destination is not retained. |
| TIME WITH TIME ZONE and TIMETZ | TIME | The default schema mapping is TIME, which cannot retain the original time zone offset. To retain a text representation of the time and the offset, validate the VARCHAR approach separately first. |
| TIMESTAMP and TIMESTAMP WITHOUT TIME ZONE | TIMESTAMP | Interpreted according to the destination time type and the session time zone. |
| TIMESTAMP WITH TIME ZONE and TIMESTAMPTZ | TIMESTAMP | Time zone conversion is applied. The original time zone marker is not retained. |
| INTERVAL | VARCHAR | Stores interval text. |
| JSON and JSONB | JSON | JSONB is converted into destination JSON. PostgreSQL JSONB indexes and storage implementations are not migrated. |
| UUID and XML | VARCHAR | Stores UUID or XML text. UUIDs are not generated automatically. |
| BIT, BIT VARYING, and VARBIT | VARCHAR | Stores bit string text. |
| INET, CIDR, MACADDR, and MACADDR8 | VARCHAR | Stores network address text. |
| POINT, LINE, LSEG, BOX, PATH, POLYGON, and CIRCLE | VARCHAR | Stores geometry text. The text format of numeric values may be normalized. |
| TSVECTOR and TSQUERY | VARCHAR | Stores the text representation. The full-text index capability is not retained. |
| ENUM and verified composite type columns | VARCHAR | Stores enumeration value or composite value text. The corresponding TYPE objects are not created. |
| One-dimensional arrays such as INTEGER[], TEXT[], and VARCHAR[] | VARCHAR | Stores array text. Arrays are not mapped to a native ARRAY type. |
| INT4RANGE, INT8RANGE, NUMRANGE, TSRANGE, TSTZRANGE, and DATERANGE | VARCHAR | Stores range text. |
| OID | BIGINT | Stores the OID value. The database objects that the OID references are not migrated. |
| REGCLASS, REGPROC, REGTYPE, and PG_LSN | VARCHAR | Stores the text representation. The source object reference capability is not retained. |
Do not treat unlisted types or any custom types as supported merely because VARCHAR can serve as a fallback. Validate the actual data first.
For the ranges of the destination DECIMAL, VARCHAR, and time types, see Basic data types. The current maximum VARCHAR size is 16 MB. Do not use the capacity limit of source TEXT, XML, or arrays as the maximum writable size in the destination.