DolphinScheduler is a distributed and scalable open-source workflow scheduling system with a visual Directed Acyclic Graph (DAG) interface. It helps you efficiently run and manage big data processes. You can use the DolphinScheduler web UI to easily create, edit, and schedule Spark jobs for AnalyticDB for MySQL.
Prerequisites
An AnalyticDB for MySQL Enterprise Edition, Basic Edition, or Data Lakehouse Edition cluster is created.
-
A job-type resource group or an interactive resource group for the Spark engine has been created in your AnalyticDB for MySQL cluster.
-
Java Development Kit (JDK) 1.8 or later is installed.
-
The IP address of the DolphinScheduler server has been added to the IP address whitelist of your AnalyticDB for MySQL cluster.
Schedule Spark SQL jobs
You can run Spark SQL jobs on AnalyticDB for MySQL in two modes: batch and interactive. The procedures are detailed in the following sections.
Batch
-
Install the spark-submit command-line tool and configure its parameters.
NoteYou only need to configure the required parameters:
keyId,secretId,regionId,clusterId, andrgName. -
Create a project.
-
Log in to the DolphinScheduler web UI. In the top navigation bar, click Project.
-
Click Create Project.
-
In the Create Project dialog box, configure parameters such as Project Name and Owned Users.
-
-
Create a workflow.
-
Click the project name to go to the Process Definition page.
-
Click Create Workflow to open the workflow DAG edit page.
-
From the component list in the left pane, drag Shell to the canvas on the right.
-
In the Current node settings dialog box, configure the following parameters:
Parameter
Description
Node Name
The name of the workflow node.
Script
The installation path of the spark-submit command-line tool and the job code for your Spark SQL job. Example:
/root/adb-spark-toolkit-submit/bin/spark-submit --class com.aliyun.adb.spark.sql.OfflineSqlTemplate local:///opt/spark/jars/offline-sql.jar "show databases" "select 100"ImportantSpecify the full installation path of spark-submit in the script. Otherwise, the scheduling task cannot find the command.
NoteFor more information about other parameters, see DolphinScheduler Task Parameters.
-
Click OK.
-
In the upper-right corner of the page, click Save. In the Basic Information dialog box, configure parameters such as Workflow Name, and then click OK.
-
-
Run the workflow.
-
In the workflow's Actions column, click the
icon to publish it. -
In the workflow's Actions column, click the
icon. -
In the Configure Parameters dialog box, configure the required parameters.
-
Click OK to run the workflow.
-
-
View workflow details.
-
In the navigation pane on the left, click Task Instances.
-
In the Operation column, click the
icon to view the execution results and logs.
-
Interactive
-
Obtain the Spark Interactive resource group endpoint.
Log on to the AnalyticDB for MySQL console. In the upper-left corner of the console, select a region. In the left-side navigation pane, click Clusters. Find the cluster that you want to manage and click the cluster ID.
-
In the navigation pane on the left, choose , and then click the Resource Groups tab.
-
Find the resource group and click Details in the Actions column to view the internal endpoint and public endpoint. You can click the
icon next to an endpoint to copy it, or click the
icon within the parentheses of the Port number to copy the JDBC connection string.In the following cases, you must click Apply for Endpoint next to Public Address to manually apply for a public endpoint.
-
The client tool used to submit Spark SQL jobs is deployed on your local machine or an external server.
-
The client tool used to submit Spark SQL jobs is deployed on an ECS instance, and the ECS instance and the AnalyticDB for MySQL cluster are not in the same VPC.
The connection information also includes fields such as the public and VPC port (default:
10000), VPC ID, VSwitch ID, driver class (org.apache.hive.jdbc.HiveDriver), and driver download URL. -
-
Create a data source.
-
Log in to the DolphinScheduler web UI. In the top navigation bar, click Datasource.
-
Click Add Data Source and select Spark as the data source type.
-
In the Add Data Source dialog box, configure the following parameters:
Parameter
Description
Data Source
Select Spark.
Datasource name
The name of the data source.
IPHost Name
Enter the connection URL from Step 1. In the URL, replace
defaultwith your actual database name and remove theresource_group=<resource_group_name>suffix.Example:
jdbc:hive2://amv-t4naxpqk****sparkwho.ads.aliyuncs.com:10000/adb_demo.Port
The port number of the Spark interactive resource group is fixed at 10000.
Username
The database account for AnalyticDB for MySQL.
Database Name
The database name of the AnalyticDB for MySQL cluster.
NoteOther parameters are optional. For more information, see MySQL Datasource.
-
Click Test Connection. After the test succeeds, click OK.
-
-
Create a project.
-
Log in to the DolphinScheduler web UI. In the top navigation bar, click Project.
-
Click Create Project.
-
In the Create Project dialog box, configure parameters such as Project Name and Owned Users.
-
-
Create a workflow.
-
Click the project name to go to the Process Definition page.
-
Click Create Workflow to open the workflow DAG edit page.
-
From the component list in the left pane, drag SQL to the canvas on the right.
-
In the Current node settings dialog box, configure the following parameters:
Parameter
Description
Data Source Type
Select Spark.
Datasource instance
Select the data source created in Step 2.
SQLType
The type of the SQL job, such as Queries or Non Query.
SQL statement
The SQL statement to run.
-
Click OK.
-
In the upper-right corner of the page, click Save. In the Basic Information dialog box, configure parameters such as Workflow Name, and then click OK.
-
-
Run the workflow.
-
In the workflow's Actions column, click the
icon to publish it. -
In the workflow's Actions column, click the
icon. -
In the Configure Parameters dialog box, configure the required parameters.
-
Click OK to run the workflow.
-
-
View workflow details.
-
In the navigation pane on the left, click Task Instances.
-
In the Operation column, click the
icon to view the execution results and logs.
-
Schedule Spark JAR jobs
-
Install the spark-submit command-line tool and configure its parameters.
NoteYou only need to configure the required parameters:
keyId,secretId,regionId,clusterId, andrgName. If your Spark JAR package is stored locally, you must also configure Object Storage Service (OSS)-related parameters, such asossUploadPath. -
Create a project.
-
Log in to the DolphinScheduler web UI. In the top navigation bar, click Project.
-
Click Create Project.
-
In the Create Project dialog box, configure parameters such as Project Name and Owned Users.
-
-
Create a workflow.
-
Click the project name to go to the Process Definition page.
-
Click Create Workflow to open the workflow DAG edit page.
-
From the component list in the left pane, drag Shell to the canvas on the right.
-
In the Current node settings dialog box, configure the following parameters:
Parameter
Description
Node Name
The name of the workflow node.
Script
The installation path of the spark-submit command-line tool and the job code for your Spark job. Example:
/root/adb-spark-toolkit-submit/bin/spark-submit --class org.apache.spark.examples.SparkPi --name SparkPi --conf spark.driver.resourceSpec=medium --conf spark.executor.instances=2 --conf spark.executor.resourceSpec=medium local:///tmp/spark-examples.jar 1000.ImportantSpecify the full installation path of spark-submit in the script. Otherwise, the scheduling task cannot find the command.
NoteFor more information about other parameters, see DolphinScheduler Task Parameters.
-
Click OK.
-
In the upper-right corner of the page, click Save. In the Basic Information dialog box, configure parameters such as Workflow Name, and then click OK.
-
-
Run the workflow.
-
In the workflow's Actions column, click the
icon to publish it. -
In the workflow's Actions column, click the
icon. -
In the Configure Parameters dialog box, configure the required parameters.
-
Click OK to run the workflow.
-
-
View workflow details.
-
In the navigation pane on the left, click Task Instances.
-
In the Operation column, click the
icon to view the execution results and logs.
-