This topic describes the usage notes and procedure for archiving data to a Lindorm instance.
Prerequisites
The source database from which you want to archive data is of one of the following types:
MySQL: ApsaraDB RDS for MySQL, PolarDB for MySQL, and AnalyticDB for MySQL V3.0
PostgreSQL: ApsaraDB RDS for PostgreSQL and PolarDB for PostgreSQL
PolarDB-X
NoteThe account of a MySQL database must have the REPLICATION CLIENT permission.
A Lindorm instance that uses LindormTable V2.2.17 or later is purchased. For more information, see Create an instance.
The Lindorm instance is registered with Data Management (DMS). When you register the Lindorm instance with DMS, select Lindorm SQL as the database type. For more information, see Register an Alibaba Cloud database instance.
The source tables whose data you want to archive have a primary key or a unique key.
NoteWe recommend that you provide a field that indicates the time of each data modification operation in the source tables. You can use this field as a filter condition when you archive data from the source tables.
Usage notes
DMS periodically runs a data archiving task only if both the source and destination databases are managed in Security Collaboration or Stable Change mode. If you need to run a data archiving task only once, the source and destination databases can be managed in any mode.
NoteIf you want to configure a periodic data archiving task and the source and destination database instances are managed in Stable Change mode, we recommend that you enable security hosting for the database instances or change the control mode of the database instances to Security Collaboration. Otherwise, the data archiving task may fail due to instance logon expiration. For more information, see the Enable security hosting section of the "Security hosting" topic and Change the control mode of an instance.
The data archiving feature is supported only in the Singapore and Indonesia (Jakarta) regions.
Billing
You are charged for the destination instance that you purchase.
Procedure
- Log on to the DMS console V5.0.
In the top navigation bar, choose .
NoteIf you use the DMS console in simple mode, move the pointer over the icon in the upper-left corner and choose
.In the upper-right corner of the Data ArchivingTickets page, click Data Archiving.
On the Ticket Application page, configure parameters to create a data archiving ticket. The following table describes the parameters.
Parameter
Required
Description
Task Name
Yes
The name of the data archiving task. We recommend that you specify a descriptive name that makes it easy to identify the task. This helps you reduce unnecessary communication.
Archiving Destination
Yes
The destination to which you want to archive data. Select Lindorm.
Lindorm Instance
Yes
The destination Lindorm instance to which you want to archive data.
Source Database
Yes
The source database from which you want to archive data.
Archiving Configuration
Yes
The one or more tables whose data you want to archive.
Optional. Specify one or more filter conditions for querying data to be archived in the specified tables. Example:
gmt_modified<='${6_month_ago}'
.NoteIf you want to use time variables in scenarios such as archiving data generated six months ago, you can set the variables in the Variable Configuration section before you configure the parameters in the Archive Configuration section.
Optional. Click Add to add more source tables.
Archive Table Mapping
No
The table settings to be used in the destination database. You can click Edit in the Actions column of a source table and specify the name, columns, database shard keys, and partition keys of the corresponding archive table in the destination database.
Variable Configuration
No
The variables that are used when you configure conditions for filtering archived data. For example, you have created a time variable named
6_month_ago
in the yyyy-MM-dd format and set the offset to - 6 Month. In this case, if the current date is August 12, 2021, the value of the${6_month_ago}
variable is 2021-02-11, which indicates February 11, 2021. For more information about how to configure time variables, see the Configure time variables section of the "Variables" topic.Post-behavior
No
Specify whether to delete the archived data from the source tables. If you select Clean up the archived data of the original table (delete-No Lock), the archived data is automatically deleted from the source tables. You can execute the
DELETE
statement to delete temporary backup tables. The temporary backup tables are generated in the source database to store the archived data when the source tables are deleted. Make sure that the source database has sufficient storage space to prevent instance unavailability caused by insufficient storage space.After the data is archived and you verify that the archived data is correct, you can create a regular data change ticket to clear the temporary backup tables from the source database.
If you do not select Clean up the archived data of the original table (delete-No Lock), the archived data is not deleted from the source tables. In this case, you need to manually delete data from the source tables and optimize the storage usage.
To delete the archived data from the source tables, create a regular data change ticket. For more information, see Normal data modify.
To optimize the storage usage of the source tables, create a lock-free change ticket. For more information, see Perform lock-free DDL operations.
If you select Verify Archived Data (This operation will be time-consuming.), DMS verifies the archived data during data archiving, including the archived table name, the source database, and the number of SQL statements. You can view the verification results on the details page.
Operation Mode
Yes
The method to be used for running the data archiving task. Valid values:
Single execution: After the data archiving ticket is approved, DMS runs the data archiving task only once.
Cyclic scheduling: After the data archiving ticket is approved, DMS runs the data archiving task based on the schedule that you specify. For more information, see the Periodic scheduling section of this topic.
Click Submit.
After the data archiving ticket is approved, DMS automatically runs the data archiving task.
If the data archiving task fails to be executed, you can click Details in the Execute step to view the logs of the data archiving task and identify the cause of the task failure. If an issue occurs due to a network or database connection failure, you can click Retry Breakpoint to restart the task.
Query the archived data. For more information, see the following section.Query the archived data
Query the archived data
Method 1: Use DMS to query the archived data
After the data archiving task is complete, perform the following steps to view the archived data: In the Basic Information section of the Ticket Details page, click View next to Target Database to go to the SQL Console tab.
On the left-side Table tab of the SQL Console tab, find the table that you want to manage, double-click the table name, and then click Execute to view the archived data.
NoteDMS automatically creates a database and tables in the destination instance based on the names of the source database and tables. Therefore, the name of the destination database is the same as that of the source database.
The following four columns of data are added to the archived table. This does not affect the use of the original archived data in the table.
Data archiving information, including the ticket number and time when data is archived
Database name
Table name
Instance ID, which is the ID that is specified when you register the instance with DMS and corresponds to the real ID of the instance
Method 2: Use Lindorm to query the archived data
LindormTable: Data Query.
Periodic scheduling
Parameter | Description |
Scheduling Cycle | The cycle based on which DMS runs the data archiving task.
|
Timed Scheduling | The scheduling method of the data archiving task. You can run the task by using one of the following methods:
|
Specified Time |
|
Specific Point in Time | The point in time of the specified days at which DMS runs the task. For example, if you set this parameter to 02:55, DMS runs the task at 02:55 on the specified days. |
Cron Expression | The CRON expression that is automatically generated based on the specified scheduling cycle and time settings. |