Quick start
This guide shows you how to use the Alibaba Cloud E-MapReduce (EMR) console to create an EMR Studio cluster, interactively develop jobs, and schedule workflows.
Background information
Prerequisites
- You have access to the EMR Studio trial.
- You have created an EMR Studio cluster. For more information, see Create an EMR Studio cluster.Note If this is the first time you create an EMR Studio cluster, the console prompts you to authorize a system role. Use your primary account to authorize the system role AliyunECSInstanceForEMRStudioRole. For more information, see Role authorization.
- Your security group rules allow inbound traffic on ports 8000, 8081, and 8443.
For more information about how to add a security group rule, see Add a security group rule.
- You have added a user. For more information, see Add a user.
Limitations
EMR Studio can be associated only with EMR compute clusters that are in the same Virtual Private Cloud (VPC).
Procedure
Step 1: Go to the data development workbench
- Go to the details page.
- Log on to the Alibaba Cloud E-MapReduce console.
- In the top navigation bar, select a region and a resource group.
- Click the Clusters tab.
- On the Clusters page, click Details for the desired cluster.
- Log on to the Alibaba Cloud E-MapReduce console.
- Add a Linux user.
For more information about adding a user, see Add a user.
- In the left-side navigation pane, choose Access Links and Ports.
- Click the link in the Studio Workspace UI row.
Enter the username and password for the user you added to access the web UI.Note Wait a few seconds for the Studio Workspace UI information to appear.
Step 2: Associate a compute cluster
After you associate a compute cluster, EMR Studio can access its resources and submit jobs to it.
- On the Associate Cluster page, click the Available Clusters tab.
Note The list shows only EMR clusters in the same VPC. You can associate three types of clusters: Hadoop, Dataflow, and DataScience.
- Select the type of cluster to associate.
- Find the cluster that you want to associate and click Associate Cluster in the Actions column.
- In the Associate Cluster dialog box, click Bind.
The association is successful when the associated cluster information appears on the Associated Clusters tab.Note The binding process takes 1 to 2 minutes.
Step 3: Develop jobs in Zeppelin
Once a cluster is associated, you can interactively develop jobs in Zeppelin notebooks. To demonstrate this, the guide uses the built-in "Airflow Scheduling Tutorial 1" as an example.
- In the left-side navigation pane, click Zeppelin.
- On the Zeppelin page, select .
The following page appears:
Area Description ① The %md interpreter renders Markdown text for notes and explanations. ② The %sh interpreter runs shell scripts to perform tasks like generating data. ③ The %hive interpreter runs Hive SQL statements. ④ Click the icon to switch the associated cluster. ⑤ Click the icon to run the current paragraph. Note Some interpreters download dependencies the first time you use them. If you see a message likeInterpreter Setting 'hive' is not ready, the download is still in progress. Wait a moment and try again.
Step 4: Write an Airflow Python script
Airflow scheduling requires you to manually write Python scripts to build DAGs. EMR Studio automatically synchronizes Python scripts from a specified OSS path to Airflow. Therefore, after you edit and upload a DAG script, you can go to the data development workbench. In the left-side navigation pane, click Airflow to open the DAGs page and view the DAGs that you created.
from airflow import DAG
from datetime import datetime, timedelta
from airflow.providers.apache.zeppelin.operators.zeppelin_operator import ZeppelinOperator
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'start_date': datetime(2018, 1, 1),
'email_on_failure': False,
'email_on_retry': False,
'retries': 0,
'retry_delay': timedelta(minutes=5),
}
with DAG('zeppelin_example_paragraph_dag',
max_active_runs=5,
schedule_interval='0 0 * * *',
default_args=default_args) as dag:
execution_date = "{{ ds }}"
raw_data_task = ZeppelinOperator(
task_id='raw_data_task',
conn_id='zeppelin_default',
note_id='2FXADMCY9',
paragraph_id='paragraph_1613703810025_1489985581',
params= {'dt' : execution_date}
)
csv_data_task = ZeppelinOperator(
task_id='csv_data_task',
conn_id='zeppelin_default',
note_id='2FXADMCY9',
paragraph_id='paragraph_1613705325984_828524031',
params= {'dt' : execution_date}
)
parquet_data_task = ZeppelinOperator(
task_id='parquet_data_task',
conn_id='zeppelin_default',
note_id='2FXADMCY9',
paragraph_id='paragraph_1613709950691_1420422787',
params= {'dt' : execution_date}
)
query_task = ZeppelinOperator(
task_id='query_task',
conn_id='zeppelin_default',
note_id='2FXADMCY9',
paragraph_id='paragraph_1613703819960_454383326',
params= {'dt' : execution_date}
)
raw_data_task >> csv_data_task >> parquet_data_task >> query_task
Step 5: Schedule a notebook job
- Enable DAG schedulingOn the DAGs page, toggle the switch from Off to On to enable DAG scheduling.
- View the details of a scheduled task
On the DAGs page, click a DAG name to open its Tree View.
On the Tree View page, you can view the details of the scheduled tasks for the DAG. - View task run status
On the Tree View page, click the icon for a task to view its run status.
Task Log Details