Help Center/ Data Replication Service/ Data Subscription/ Creating a Data Subscription Task
Updated on 2024-09-25 GMT+08:00

Creating a Data Subscription Task

Supported Databases

Table 1 Database information

DB Engine

Data Type

RDS for MySQL

Version 5.6 and 5.7

  • Data update
  • Structure update

A subscription task has many subscription object and operation constraints. You are advised to use data synchronization from MySQL to Kafka with higher performance and stability for data subscription.

Precautions

You can create a subscription task to obtain the data change information of key services in the database. This type of information is often required by downstream services. Data subscription helps cache incremental data and provides a unified SDK interface for downstream applications to subscribe to and consume the incremental data.

To create a data subscription task successfully, you need implement the following two steps:

  1. Create a data subscription task on the DRS console.
  2. Use the SDK API of DRS to access the data subscription channel and subscribe to and consume incremental data.

The following describes constraints on data subscription tasks. Before using DRS, you need to ensure that the source and destination databases meet the following constraints.

Table 2 Precautions

Type

Restrictions

Restrictions on subscription objects

  • Only RDS for MySQL DB instances are supported.
  • Currently, data subscription objects support only tables.
  • The binlog_row_image format of binlogs must be set to full.
  • MySQL supports only the MyISAM and InnoDB storage engines.
  • MySQL supports only the LATIN1, GBK, UTF8, UTF8MB4, and BINARY character sets.
  • Subscription data is provided by transaction. Only the scenario where the data volume of a single transaction is less than 10 MB is supported.
  • During data subscription, do not upgrade the source MySQL database across major versions. Otherwise, data may become inconsistent or the subscription task may fail (data, table structures, and keywords may cause compatibility changes after the cross-version upgrade). You are advised to create a subscription task again if the source MySQL database is upgraded across major versions.

Precautions

  • During data subscription, deleting subscription objects is not allowed.
  • A subscription task can be subscribed to and consumed by only one downstream SDK. If multiple downstream SDKs need to subscribe to the same RDS DB instance, you can create multiple subscription channels. The RDS DB instances subscribed by these subscription tasks have the same instance ID.
  • A downstream SDK cannot subscribe to and consume multiple subscription tasks.
  • Currently, the VPC network is supported, but the container network in a VPC is not supported.
  • If a DRS subscription task fails due to a source database exception or network interruption, resume the subscription task on the Data Subscription page. For details, see Resuming a Subscription Task.
  • A subscription task has many subscription objects and operation constraints. You are advised to use the synchronization from MySQL to Kafka with higher performance and stability for data subscription. For details about the differences between data subscription and synchronization from MySQL to Kafka, see What Are Differences Between Data Subscription and Synchronization from MySQL to Kafka?
  • After you select Structure update and Data update, DRS displays the DDL and DCL update operations of the entire instance (not the selected database) without filtering. If necessary, you can use the SDK to filter the required data.

Prerequisites

Procedure

This section describes how to create a data subscription task on the DRS console.

The following uses MySQL as an example to describe how to create a subscription task. To configure subscription tasks of other DB engines, you can refer to the following procedures.

  1. On the Data Subscription Management page, click Create Subscription Task.
  2. On the Select Subscription Source page, specify Region, Task Name, Description, and subscription source details, and click Next.

    Figure 1 Subscription task information
    Table 3 Task and recipient description

    Parameter

    Description

    Region

    The region where your service is running. You can change the region. To reduce latency and improve access speed, select the region closest to your services.

    Project

    The project corresponds to the current region and can be changed.

    Task Name

    The task name must start with a letter and consist of 4 to 50 characters. It can contain only letters, digits, hyphens (-), and underscores (_).

    Description

    The description consists of a maximum of 256 characters and cannot contain special characters !=<>'&"\

    Figure 2 Subscription source information
    Table 4 Subscription source information

    Parameter

    Description

    Instance Type

    Select RDS DB instance.

    Source DB Engine

    Select MySQL.

    RDS DB instance

    Select an RDS DB instance you have created.

    Enterprise Project

    An enterprise project you would like to use to centrally manage your cloud resources and members. Select an enterprise project from the drop-down list. The default project is default.

    For more information about enterprise projects, see Enterprise Management User Guide.

    To customize an enterprise project, click Enterprise in the upper right corner of the console. The Enterprise Project Management Service page is displayed. For details, see Creating an Enterprise Project in Enterprise Management User Guide.

    Tags

    This setting is optional. You can use tags to manage subscription tasks. Each task can have up to 20 tags.

    If your organization has configured tag policies for DRS, add tags to tasks based on the policies. If a tag does not comply with the policies, task creation may fail. Contact your organization administrator to learn more about tag policies.

    After a task is created, you can view its tag details on the Tags tab. For details, see Tag Management.

    If a task fails to be created, DRS retains the task for three days by default. After three days, the task automatically stops.

  3. On the Select Subscription Object page, wait until the instance is successfully created, select the data subscription object, and click Next.

    Figure 3 Subscription objects

    Table 5 Subscription objects

    Parameter

    Description

    Subscription Type

    Subscription types include data update and structure update.

    • Data update

      Subscribes to the Incremental updates of the selected data.

    • Structure update

      Subscribes to the structure creation, deletion, and modification of all objects in an instance, SDK is needed to filter the required data.

    Subscription Object

    Currently, data subscription objects support only tables. You can select a subscription object based on your service requirements.

    If the source database is changed, click in the upper right corner before selecting migration objects to ensure that the objects to be selected are from the changed source database.

    You can also search for subscription objects to quickly select the required objects.

  4. On the Confirm Task page, specify Send Notifications and SMN Topic, confirm that the configured information is correct, select the check box before the agreement, and click Submit.

    Figure 4 Task startup settings

    Table 6 Task startup settings

    Parameter

    Description

    Send Notifications

    This parameter is optional. After enabled, select a SMN topic. If the status or latency metric of the data subscription task is abnormal, DRS will send a notification.

    SMN Topic

    This parameter is available only after you enable Send Notifications and create a topic on the SMN console and add a subscriber.

    For details, see Simple Message Notification User Guide.

    Synchronization delay threshold

    A synchronization delay indicates a time difference (in seconds) of synchronization between the source and destination database.

    If the synchronization delay exceeds the threshold you specify, DRS will send alarms to the specified recipients. The value ranges from 0 to 3,600. To avoid repeated alarms caused by the fluctuation of delay, an alarm is sent only after the delay has exceeded the threshold for six minutes.

    NOTE:
    • Before setting the delay threshold, enable Send Notifications.
    • If the delay threshold is set to 0, no notifications will be sent to the recipient.

  5. After the task is submitted, view and manage it on the Data Subscription Management page.

    • You can view the task status. For more information about task status, see Task Statuses.
    • You can click in the upper-right corner to view the latest task status.
    • By default, DRS retains a task in the Configuration state for three days. After three days, DRS automatically deletes background resources, but the task status remains unchanged. When you reconfigure the task, DRS applies for resources again.
    • By default, DRS retains a task in the Abnormal state for 14 days. After 14 days, DRS automatically deletes background resources, but the task status remains unchanged. When you reconfigure the task, DRS applies for resources again.

    After a subscription task is created, you can use an SDK to subscribe to incremental data in the subscription task in real time. For details about the operations and precautions, see SDK Usage Instructions.