AnalyticDB for MySQL Enterprise Edition, Basic Edition, and Data Lakehouse Edition and Data Warehouse Edition all support the task orchestration feature of DMS to orchestrate, schedule, manage, and monitor AnalyticDB for MySQL tasks. This topic describes how to use DMS for task development and scheduling.
Background information
-
Challenges: event scheduling
Traditional database event scheduling, such as the MySQL Event Scheduler, is powerful but has several limitations:
-
High barrier to entry: Users must master special SQL syntax for event definitions (
CREATE EVENTandALTER EVENT) and cannot configure events through a simple interface. -
Strong dependency on the database kernel: The kernel must support and enable the event scheduler.
-
Limited to a single database: Scheduling can only be performed for a single database and cannot be coordinated with other databases or tools.
-
Difficult to track: Users cannot view the execution status, execution history, or runtime of scheduled events.
-
Difficult to maintain: Users cannot pause or rerun events, and failed events cannot be recovered.
-
No notifications: Event execution status (success or failure) cannot be proactively sent to users via SMS, email, or other channels.
-
-
Solution: DMS task orchestration
The task orchestration feature of DMS resolves the preceding issues. It does not rely on the event scheduling capability of the database kernel. Instead, it is an independent external task orchestration and scheduling system. Key features include:
-
Supports multiple database engines (MySQL, Oracle, PostgreSQL, SQL Server, and others) and various ecosystem tools (data migration, backup, cross-database analysis, and others) to enable cross-database and cross-product workflows.
-
Provides a visual editing interface where you can create scheduling tasks through drag-and-drop operations and simple configurations.
-
Supports multiple notification mechanisms such as DingTalk, SMS, and email.
-
Supports various O&M operations such as pause, terminate, and rerun.
-
Sample data
In this example, the database name is adb_test. Three tables are created in this database: orders, finish_orders, and large_finish_orders.
create database adb_test;
create table orders(
order_id bigint not null comment'order ID',
order_status varchar not null comment'order state',
total_price decimal(15,2) not null comment'total price',
order_date date not null comment'orderdate',
PRIMARY KEY (order_id)
);
create table finish_orders(
order_id bigint not null comment'order ID',
total_price decimal(15,2) not null comment'order state',
order_date date not null comment'total price',
PRIMARY KEY (order_id)
);
create table large_finish_orders(
order_id bigint not null comment'order ID',
total_price decimal(15,2) not null comment'order state',
order_date date not null comment'total price',
PRIMARY KEY (order_id)
);
Overview
This topic uses an AnalyticDB for MySQL Data Warehouse Edition cluster as an example to describe the job scheduling process. You use the task orchestration feature of DMS to filter completed orders with an order amount greater than 10,000 USD from the orders table in an AnalyticDB for MySQL database.
|
Step |
Description |
|
Create a task flow. |
|
|
In this step, create the following two task nodes in the target task flow:
|
|
|
Enable the target task and configure it to run periodically. |
Step 1: Create a task flow
-
Log on to the AnalyticDB for MySQL console. In the upper-left corner, select the region where the cluster is located. In the left-side navigation pane, click Clusters. Find the target cluster and click the cluster ID.
-
In the left-side navigation pane, choose .
Note-
If this is the first time you log on to an AnalyticDB for MySQL cluster database through DMS (new version) to use the data asset management feature, you must first enter the database logon information. For more information, see Log on to a database.
-
If you have previously logged on to an AnalyticDB for MySQL cluster database and the cluster control mode is set to Flexible Management or Stable Change, but you did not select Remember Password when entering the database logon information, after you go to the DMS console, you must enter the password of the target database account in the dialog box that appears before you can proceed. For more information about control modes, see Control modes.
-
The unified data management feature is not supported for AnalyticDB for MySQL clusters in the Indonesia (Jakarta) region.
-
-
In the top menu bar, choose Integration & Development (DTS).
-
In the left-side navigation pane, choose .
-
Create a new task flow. In this example, the task flow is named Order Filtering.
-
Click Create Task Flow.
-
In the New Task Flow dialog box, enter the Task Flow Name and Description, and then click OK.
-
Step 2: Create task nodes
-
On the task orchestration page for Order Filtering, create and configure the following two task nodes:
-
Order Cleansing
-
In the left-side pane, select Single Instance SQL and drag it to the blank canvas on the right.
-
Select the newly added task node and click the
icon to rename it Order Cleansing. -
Double-click the task node or click the
icon to edit the task node. -
Select the target database from the database drop-down list.
-
In the dialog box below the target database, enter the task statement and click Save. The statement is as follows:
insert into finish_orders select order_id,total_price,order_date from orders where order_status = 'F';NoteIf Auto Save is selected, the SQL statement is saved automatically after you enter it.
-
-
Large Order Generation
-
In the left-side pane, select Single Instance SQL and drag it to the blank canvas on the right.
-
Select the newly added task node and click the
icon to rename it Large Order Generation. -
Double-click the task node or click the
icon to edit the task node. -
Select the target database from the database drop-down list.
-
In the dialog box below the target database, enter the task statement and click Save. The statement is as follows:
insert into large_finish_orders select order_id,total_price,order_date from finish_orders where total_price > 10000;NoteIf Auto Save is selected, the SQL statement is saved automatically after you enter it.
-
-
-
On the task flow canvas, hover over the
Order Cleansingnode. Click the small circle on the right side of the node and drag a connection line to theLarge Order Generationnode to create a dependency between the two task nodes.
Step 3: Configure task flow scheduling
-
In the Scheduling Settings section below the task flow canvas, turn on the Enable Scheduling switch and configure the relevant parameters.
NoteIn this example, the scheduling task is set to run daily at 01:00 from 2023-02-01 to 2023-02-28. You can also customize the scheduling task based on your business needs. For more information about scheduling configuration parameters, see Configure scheduling.
-
Publish the task flow.
-
Click Publish in the upper-left corner of the canvas.
-
In the Publish dialog box, enter the Remarks information and click OK to publish the task flow.
-
-
Confirm the publication status.
-
Click Go to O&M above the canvas.
-
On the right side of the page, check the publication status of the task flow.
-
Published: The task flow is in the published state.
-
Unpublished: The task flow is in the unpublished state.
-
-