Help Center/ Data Admin Service/ User Guide/ MySQL/ Task Management/ Scheduling Tasks (Not Promoted)
Updated on 2025-01-17 GMT+08:00

Scheduling Tasks (Not Promoted)

DAS allows you to execute SQL statements by scheduling tasks. Scheduling types include immediate, scheduled, and periodic. You can select a scheduling type when creating a task. Error control and transaction control can be performed on SQL statements during scheduling, and task dependency chains can be set for dependent SQL statements.

Concurrent tasks cannot be scheduled. To execute concurrent tasks, enable Event Scheduler to use the event capability provided by the database. For details, see Enabling or Disabling Event Timer.

Creating a Scheduling Task

  1. Log in to the Huawei Cloud console.
  2. Click in the upper left corner and select a region and project.
  3. Click in the upper left corner, and under Databases, click Data Admin Service.
  4. In the navigation pane on the left, choose Development Tool.

    You can also click Go to Development Tool on the overview page.

  5. Locate the DB instance that you want to log in to and click Log In in the Operation column.
  6. On the top menu bar, choose Background Tasks > Task Scheduling.

    You can create a scheduling task only after agreeing to save SQL statements in a database.

  7. On the Scheduling Tasks tab, click Create Task.
  8. On the displayed page, enter a task name and specify a scheduling type and execution time tolerance.

    Figure 1 Creating a task
    Table 1 Parameter description

    Parameter

    Description

    Task Name

    Task name, which is user-defined.

    Type

    The options can be Immediate, Scheduled, and Periodic. You can set a scheduling type as required.

    • Immediate: indicates that a scheduled task is executed immediately after being submitted. The task is executed only once.
    • Scheduled: indicates that a task is executed at a scheduled point in time after being submitted. The task is executed only once.
    • Periodic: indicates that a task is executed periodically at the specified time after being submitted.

    Execution Time Tolerance (s)

    Refers to how many seconds the system keep executing this task after the expected execution time comes.

    The default value is 3600. The value ranges from 1 to 86,400.

  9. Under SQL Statements, click Add. On the displayed page, set parameters as needed and click Save.

    Figure 2 Adding SQL statements
    Table 2 Parameter description

    Parameter

    Description

    Group Name

    Group name, which is user-defined.

    Instance

    Target instance name.

    Database

    Associated database.

    SQL Statements

    You can manually input SQL statements or import existing SQL files.

    Skip Errors

    Configuring this parameter is recommended.

    After this parameter is configured, the system will skip any errors detected when SQL statements in the SQL group are being executed. If this function is disabled, the system will stop executing SQL statements.

    Enable Transactions

    Configuring this parameter is recommended.

    After this parameter is configured, SQL statements in the current SQL group will be executed as a transaction, and if a DML error occurs, a rollback will be performed. If this function is disabled, each SQL statement in the group is executed separately.

    Dependent SQL Group

    The system executes all SQL statements in the dependent SQL group first and then those statements in the current group.

    Allow Concurrent Execution

    Configuring this parameter is recommended.

    After this parameter is configured, the system will concurrently execute SQL statements in the current SQL group and other SQL groups, except for dependent SQL groups.

    CAUTION:

    SQL statements in the current SQL group are executed still in serial mode.

  10. Click Submit at the bottom of the Create Task tab.

Managing Scheduling Tasks

Tasks are displayed on the Scheduling Tasks and Finished Tasks tab pages by status.

  • Scheduling Tasks: The scheduling tasks are periodic tasks that are being scheduled or paused.

    On the Task Scheduling page, click the Scheduling Tasks tab.

    You can search for tasks by status, scheduling type, task ID, or task name.

    Figure 3 Searching for a task
    You can also perform the following operations on scheduling tasks:
    • View Details: Click it to view the task information.
      Figure 4 Details

      Click the name of a scheduling task to go to the Task Info page and click Manually Execute to trigger a scheduling immediately. After the task is successfully executed, view execution details on the Scheduling Execution Records page.

      In the SQL Groups area, click View Details. On the displayed page, view, modify, copy, and delete SQL statements.

      Figure 5 Managing SQL statements
    • View Execution Records: Click it to view the task execution details and logs.
    • View Log: Click it to view log details.
    • Terminate: Click it to stop a scheduled task. A stopped task will be moved to the Finished Tasks list.
    • Pause: Click it to pause a task. The task status changes from Scheduling to Pause. You can also click Resume to restore the scheduling.
  • Finished Tasks: Tasks in the Finished Tasks list are periodic tasks that have been terminated or immediate and scheduled tasks that have completed.

    On the Task Scheduling page, click the Finished Tasks tab.

    You can search for tasks by status, scheduling type, task ID, or task name.

    Figure 6 Viewing task information

    You can also perform the following operations on scheduling tasks:

    • View Details: Click it to view the task information.

      Click the name of a finished task that is periodically scheduled or starts immediately. On the displayed page, click Manually Execute. After the execution completes, view execution details on the Scheduling Execution Records page.

      In the SQL Groups area, click View Details. On the displayed page, view, modify, copy, and delete SQL statements.

    • View Execution Records: Click it to view the task execution details, group execution status, SQL statements, and group logs.
    • View Log: Click it to view log details.
    • Delete: Click it to delete a task from the database.

Creating a Task Scheduling Alarm Rule

To monitor the status of DAS tasks, you can create an alarm rule on the Cloud Eye console. After the alarm rule is created, if a metric reaches the specified threshold or there is an event, Cloud Eye immediately informs you of the exception through SMN.

  1. Log in to the Huawei Cloud console.
  2. Choose Service List > Cloud Eye.
  3. In the navigation pane, choose Alarm Management > Alarm Rules.
  4. Click Create Alarm Rule in the upper right corner.
  5. On the displayed page, set parameters as prompted.

    1. Configure basic information of the alarm rule.
      Figure 7 Basic information
      Table 3 Parameters

      Parameter

      Description

      Name

      Alarm rule name. The system generates a random name, which you can modify.

      Example value: alarm-b6al

      Description

      (Optional) Supplementary information about an alarm rule

    2. Select an object to be monitored and set alarm parameters.
      Figure 8 Alarm parameters
      Table 4 Alarm parameters

      Parameter

      Description

      Example Value

      Alarm Type

      Alarm type, which can be Metric or Event

      Metric

      Event Type

      If you select Event for Alarm Type, you need to select an event type, which can be System event or Custom event.

      System event

      Event Source

      If you select Event for Alarm Type, you need to select an event source.

      • If you select System event for Event Type, you need to select a cloud service for which the event is generated.

        Example value: Elastic Cloud Server

      • If you select Custom event for Event Type, the event source must be the same as the reported field and written in the Service.Item format.

      -

      Monitoring Scope

      If you select Metric for Alarm Type, you need to select a resource scope to which the alarm rule applies. You can select All resources, Resource groups, or Specific resources.

      NOTE:
      • If you select All resources, an alarm will be triggered when any resource of the current cloud product meets the alarm policy. To exclude resources that do not need to be monitored, click Select Resources to Exclude.
      • If you select Resource groups, an alarm will be triggered when any resource in the group meets the alarm policy. To exclude resources that do not need to be monitored, click Select Resources to Exclude.
      • If you select Specific resources, click Select Specific Resources and select resources.

      All resources

      Method

      • Configure manually: If you select Event for Alarm Type and Custom event for Event Type, Configure manually is selected by default.
      • Associate template: If an associated template is modified, the alarm policy will be modified as well.
        NOTE:
        • If you select Cloud product for Resource Level, only changes to policies for the specified cloud product in an associated template will be automatically synchronized.
        • If you select Specific dimension for Resource Level, only changes to policies for the specified dimension in an associated template will be automatically synchronized.

      Configure manually

      Alarm Policy

      If you select Event for Alarm Type and Custom event for Event Type, you need to set Alarm Policy.

      If you select Custom event for Event Type, as long as an event occurs (for example, the running status is abnormal), an alarm will be triggered.

      NOTE:

      A maximum of 50 alarm policies can be added to an alarm rule. If any one of these alarm policies is met, an alarm is triggered.

      -

    3. Set alarm notification parameters as prompted.
      Figure 9 Alarm notification parameters
      Table 5 Alarm notification parameters

      Parameter

      Description

      Alarm Notifications

      Whether to send notifications to users via SMS, email, voice notification, HTTP, HTTPS, FunctionGraph (function), FunctionGraph (workflow), WeCom chatbot, DingTalk chatbot, Lark chatbot, and WeLink chatbot.

      Notified By

      You can select Notification groups or Topic subscriptions.

      • Notification groups: Configure notification templates on Cloud Eye.
      • Topic subscriptions: Configure notification templates on SMN.

      Notification Policies

      If Notification policies is selected for Notified By, you need to select one or more notification policies. You can specify the notification group, window, template, and other parameters in a notification policy.

    4. In the Advanced Settings area, configure an enterprise project and a tag.
      Figure 10 Advanced Settings
      Table 6 Parameters

      Parameter

      Description

      Enterprise Project

      Enterprise project that an alarm rule belongs to. Only users with the enterprise project permissions can view and manage the alarm rule. For details about how to create an enterprise project, see Creating an Enterprise Project.

      Tag

      A tag is a key-value pair. Tags identify cloud resources so that you can easily categorize and search for your resources. You are advised to create predefined tags on TMS. For details, see Creating Predefined Tags.

      If your organization has configured tag policies for Cloud Eye, you need to add tags to alarm rules based on tag policies. If a tag does not comply with the policies, an alarm rule may fail to be created. Contact your organization administrator to learn more about tag policies.

      • A key can contain a maximum of 128 characters, and a value can contain a maximum of 225 characters.
      • A maximum of 20 tags can be created.
    5. Click Create.

    After the alarm rule is created, if a metric reaches the specified threshold, Cloud Eye will immediately inform you of an error.

For more information, see Creating an Alarm Rule.