This topic describes how to archive data to Lindorm.
Prerequisites
The following types of source databases are supported:
-
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 2.0
NoteThe account of a MySQL database must have the REPLICATION CLIENT permission.
-
You have purchased a LindormTable instance of version 2.2.17 or later. For more information about how to purchase an instance, see Create an instance.
You have added the destination Lindorm database to Data Management Service (DMS). When you add the database, ensure that you select Lindorm-SQL. For more information, see Add a cloud database.
The source tables to be archived must have a primary key or a unique key.
NoteWe recommend that you include a field that indicates the modification time in the source tables. This lets you use the business modification time as a filter condition for archiving.
Notes
To run periodic archiving tasks, the control mode for both the source and destination databases must be Security Collaboration or Stable Change. For one-time archiving tasks, there are no restrictions on the control mode.
If your instances are in Stable Change control mode, you must enable security hosting or change the control mode to Security Collaboration before you run a periodic archiving task. This prevents task failures that are caused by instance logon expiration. For more information, see Enable security hosting and Change the control mode.
Billing
You are charged for the destination instance that you purchase.
Archive data
- 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 of the DMS console and choose . In the upper-right corner, click Data Archiving.
On the Create Data Archiving Ticket page, configure the parameters.
Configuration Item
Required
Description
Task Name
Yes
Enter a clear and descriptive task name to improve communication efficiency.
Archive Destination
Yes
Select Lindorm.
Lindorm Instance
Yes
Search for and select the destination Lindorm instance.
Source Database
Yes
Search for and select the source database.
Archive Configuration
Yes
Select the tables whose data you want to archive.
Optional: Enter a filter condition for the data to be archived. Example:
gmt_modified<='${6_month_ago}'.NoteTo use a time variable, for example, to archive data from six months ago, configure the variable in the Variable Configuration section first.
Optional: Click Add to add multiple source tables.
Archived Table Mapping
No
In the Actions column, you can click Edit next to a table name to edit the table name, column information, sharding key, and partition key for the archived table in the destination database.
Variable Configuration
No
You can use the configured variables when you set filter conditions. For example, set the time variable to
6_month_ago, the time format to yyyy-MM-dd, and the offset to -6 months. If the current date is 2021-08-12, the value of the${6_month_ago}variable is 2021-02-11. For more information about how to configure time variables, see Configure time variables.Post Actions
No
If you select Clean up archived data from the source table (delete-lockless), the system automatically deletes the archived data from the source table after the archive task is complete. The deletion is performed using a lockless
DELETEstatement. However, a temporary backup table that stores the archived data is created in the source database. Make sure that the source database has sufficient space to prevent the instance from becoming unavailable.Clean up the temporary backup table: After you confirm that the data is archived correctly, you can create a regular data change ticket to clean up the temporary backup table in the source database.
If you do not select Clean up archived data from the source table (delete-lockless), you must manually delete the data from the source table and optimize the table space after the data is successfully archived.
Delete data from the source table: Create a regular data change ticket to delete the archived data from the database. For more information about how to create a regular data change ticket, see Regular data change.
Optimize the source table space: Create a lockless change ticket to optimize the source table space. For more information about how to create a lockless change ticket, see Use a lockless change ticket to perform lockless schema evolution.
If you select Validate archived data, the system validates the archived data when the archive task runs. The validation includes the archived table name, source database, and the number of SQL statements. You can click Validation Details to view the details.
Run Mode
Yes
Select a run mode. The following modes are supported:
One-time Execution: After the ticket is approved, the archive task runs only once.
Recurring Schedule: After the ticket is approved, the archive task runs based on the configured recurring schedule. For more information about the configuration, see Recurring schedule.
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 data after archiving
Method 1: Query archived data using DMS
After the data archive task is complete, go to the Basic Information section on the Ticket Details page and click View next to Destination Database.
On the SQL Console page, find the destination table in the list of tables on the left, double-click the table name, and click Execute to view the archived data.
NoteThe system automatically creates a database and tables in the destination instance that have the same names as the source database and tables.
Four columns are added to the archived table. These columns do not affect the raw data.
Archive information (ticket number and archive time)
Database name
Table name
Instance ID (The ID assigned when the instance was added to DMS, which corresponds to the actual instance ID.)
Method 2: Query archived data using Lindorm
Query data from LindormTable.
Recurring schedule
Configuration Item | Description |
Scheduling Period | Select a scheduling period for the task:
|
Timed Scheduling | Two timed scheduling methods are available:
|
Specified Day/Date |
|
Specific Time | Set the specific time to run the task. For example, if you set the time to 02:55, the system runs the task at 02:55 on the specified days. |
Cron Expression | You do not need to configure this item manually. The system automatically generates a cron expression based on the period and time that you configure. |