This topic shows you how to synchronize an entire MySQL database to MaxCompute in real time by using a serverless synchronization task.
Prerequisites
-
You have a MySQL data source and a MaxCompute data source. For more information, see Data source configuration.
-
Connectivity tests for ApsaraDB RDS for MySQL instances and MaxCompute projects pass automatically if no whitelist is configured. If a whitelist is configured, add the required IP addresses to the whitelist. For a list of IP addresses, see Network connectivity and whitelist configuration.
Limitations
Synchronizing source data to MaxCompute external tables is not supported.
Create a serverless synchronization task
A serverless synchronization task is a fully managed, pay-as-you-go data synchronization service. It allows you to synchronize data by focusing on your business logic without managing underlying resource groups or network configurations.
Step 1: Create the serverless synchronization task
Log on to the DataWorks console. In the target region, click in the left-side navigation pane. Select a workspace from the drop-down list and click Go to Data Integration.
-
In the left-side navigation pane, click Serverless Synchronization Task.
-
On the Serverless Synchronization Task page, select MySQL from the Source drop-down list and MaxCompute from the Destination drop-down list. Then, click Create Serverless Synchronization Task.
Step 2: Configure basic information
-
To use an existing data source, click Use Existing Data Source and select the data source. The system automatically populates the data source information.
-
The Data Source and Data Destination selected here do not need to be added as data sources in Data Integration or the management center in advance. You can also directly configure the details of the Data Source or Data Destination here.
-
After you configure the source and destination information, click Test. For ApsaraDB RDS for MySQL instances and MaxCompute projects, connectivity tests pass automatically if no whitelist is configured. If a whitelist is configured, add the required IP addresses to the whitelist. For a list of IP addresses, see Network connectivity and whitelist configuration.
On the basic configuration page, set Synchronization Type to Real-time Full Database, and select Schema Migration, Full Synchronization, and Incremental Synchronization for Synchronization Steps. In the Data Source section, select the Alibaba Cloud Account, Region (such as China (Shanghai)), and Instance ID, and then enter the Database Name (such as testdb), Username, and Password. Select Encoding (UTF-8) and Time Zone (Asia/Shanghai). In the Data Destination section, select the Alibaba Cloud Account, Region, and MaxCompute Project Name. Set Default Access Identity to Alibaba Cloud Account. Click Test for both the source and destination to verify that both show Connected. Then, set the Resource Usage CU count (such as 1 CU).
Step 3: Configure the task
1. Select databases and tables
After the connectivity test passes, the synchronization task automatically retrieves the databases and tables from the current data source. For MySQL-to-MaxCompute synchronization, you can select Specified Databases and Tables or Use Regular Expressions for Table Selection.
Select tables from the Source Databases/Tables list and click the
icon to add them to the Selected Databases/Tables area.
The upper-right corner of the selected databases and tables area provides a Batch Modify Selected Tables function. A maximum of 5,000 tables can be synchronized.
2. Configure destination table mappings
In the Operations column, click Refresh Mapping. Then, configure the table name mapping, Field Type Mapping, and schema name mapping.
On the destination table mapping page, fields such as the destination database name, destination table name, destination table synchronization primary key, and DML rule configuration are displayed as Pending Refresh before refreshing. After you click Refresh Mapping, the fields are automatically populated. To perform operations on multiple records, use the Batch Refresh Mapping, Batch Remove, and Batch Modify buttons at the bottom of the page.
3. Configure alerts and advanced parameters
In the upper-right corner, click Alert Settings, Configure Advanced Parameters, or DDL Capability Configuration, and configure the settings as prompted. In the alert configuration panel, you can set alert rules (such as triggers for task failures or delays) and notification methods (such as email, SMS, or DingTalk). In the advanced configuration panel, you can adjust runtime parameters (such as concurrency, rate limiting, and dirty data handling policies). In the DDL rules panel, you can configure handling policies (synchronize, ignore, or report errors) for DDL changes (such as adding columns, deleting columns, or modifying column types).
Step 4: Complete the configuration
After you finish the configuration, click Complete.
The first time you click Complete, a Configuration Check runs automatically. Note that this Configuration Check is a pre-check and does not block the Complete.
In the Configuration Check dialog box that appears, you can view the results of each check item (such as task configuration check, dynamic partition configuration check, table configuration check, MySQL Binlog check, and field assignment check). After all check items show Passed, click Close.
Start the synchronization task
-
Starting the task triggers another Configuration Check. Note that this Configuration Check is mandatory. If the check fails, the task cannot start.
-
The items in the configuration check vary depending on the synchronization task.
-
The first time you start the task, the system checks whether you have the required permissions, which are the same as those needed to purchase a pay-as-you-go serverless resource group. Only users with both the AliyunBSSOrderAccess and AliyunDataWorksFullAccess policies can start the task.
On the serverless synchronization task page, find the task you created and click Start in the Operations column.
At this point, the task status is displayed as Not Submitted.
-
After starting, the task enters the environment preparation stage. During this stage, the system provisions dedicated resources for the task. This process usually takes a few minutes.
The task status is displayed as Environment Pre-check, and the execution overview includes three progress items: Schema Migration (Table 0/1), Full Initialization (Database 0/1), and Real-time Synchronization (Pending).
-
After the task starts, the status changes to Running.
In the task list, you can view the Execution Overview of the task, including the progress of three subtasks: Schema Migration, Full Initialization, and Real-time Synchronization.
Monitor and manage the synchronization task
View task details
Click the task name in the Name/ID column or click the content in the Execution Overview column to open its details page.
-
Basic Information: Includes data source information, billing order ID, and the synchronization solution.
-
Execution Status: Shows the specific execution status of each step of the synchronization task. You can also view the operational log, failover information, and resource utilization.
-
Details: Includes detailed information on schema migration, full data initialization, and real-time synchronization.
Modify task configuration
-
In the Operations column for the target serverless synchronization task, click Edit to open the task configuration page.
Edit is located in the More drop-down menu of the Actions column.
-
Add, delete, or modify the tables to synchronize, then click Complete.
-
In the Actions column, click Apply Updates.
-
Apply Updates automatically runs a pre-check, which will block Apply Updates if the check fails.
-
Apply Updates involves fewer checks than an initial startup. Because the resources have already been initialized, Apply Updates does not include the resource preparation stage that an Initial Startup does.
-
References
-
To view task order details and advanced parameter configurations, see Appendix.
-
If you encounter issues with a serverless real-time synchronization task, see Real-time synchronization FAQ.