Archive data to Lindorm

更新时间:
复制 MD 格式

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

    Note

    The 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.

    Note

    We 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.

Note

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

  1. Log on to the DMS console V5.0.
  2. In the top navigation bar, choose Solution > Data Archiving.

    Note

    If you use the DMS console in simple mode, move the pointer over the 2023-01-28_15-57-17.png icon in the upper-left corner of the DMS console and choose All Features > Solution > Data Archiving.

  3. In the upper-right corner, click Data Archiving.

  4. 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}'.

      Note

      To 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 DELETE statement. 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.

      1. 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.

      2. 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.

  5. Click Submit.

  6. 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.

  7. Query the data after it is successfully archived.

Query data after archiving

Method 1: Query archived data using DMS

  1. 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.

  2. 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.

    Note

    The 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:

  • Hour: Runs the task at specified hours. You must configure a timed schedule.

  • Day: Runs the task once a day. You must configure a specific time for the daily schedule.

  • Week: Runs the task once on specified days of the week. You must configure the specified days and a specific time.

  • Month: Runs the task once on specified days of the month. You must configure the specified days and a specific time.

Timed Scheduling

Two timed scheduling methods are available:

  • Fixed Interval:

    • Start Time: The time to start running the task.

    • Interval: The interval at which the task runs, in hours.

    • End Time: The time to stop running the task.

    For example, if you set Start Time to 00:00, Interval to 6 hours, and End Time to 20:59, the system runs the task at 00:00, 06:00, 12:00, and 18:00.

  • Specified Times: Select the specific times at which to run the task.

    For example, if you select 0 and 5, the system runs the task at 00:00 and 05:00.

Specified Day/Date

  • If the scheduling period is Week, select the days of the week on which to run the task. You can select multiple days.

  • If the scheduling period is Month, select the days of the month on which to run the task. You can select multiple days.

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.