Configure a Spark job

Updated at:

This topic describes how to configure a Spark job.

Prerequisites

Ensure you have created a project. For more information, see project management.

Procedure

  1. Go to the Projects page in Data Platform.

    1. Log in to the E-MapReduce console with your Alibaba Cloud account.

    2. In the top navigation bar, select the region and resource group.

    3. Click the Data Development tab.

  2. In the row of the project you want to edit, click Edit Job.

  3. Create a Spark job.
    1. On the left side of the page, right-click the target folder and select Create Job.
    2. In the Create Job dialog box, enter a Job Name and job description, and select Spark from the Job Type drop-down list.
      This creates a Spark job, which is submitted by using the following command:
      spark-submit [options] --class [MainClass] xxx.jar args
    3. Click OK.
  4. Edit the job content.
    1. In the job content text box, enter the command-line parameters to submit the job.
      You only need to enter the parameters that follow spark-submit.
      The following examples show how to enter the parameters for a Spark job and a PySpark job:
      • Create a Spark job.
        To create a Spark job named Wordcount, configure the application parameters as follows:
        • The complete command to run from the command line is as follows:
          spark-submit --master yarn-client --driver-memory 7G --executor-memory 5G --executor-cores 1 --num-executors 32 --class com.aliyun.emr.checklist.benchmark.SparkWordCount emr-checklist_2.10-0.1.0.jar oss://emr/checklist/data/wc oss://emr/checklist/data/wc-counts 32
        • In the job content text box, enter the following command:
          --master yarn-client --driver-memory 7G --executor-memory 5G --executor-cores 1 --num-executors 32 --class com.aliyun.emr.checklist.benchmark.SparkWordCount ossref://emr/checklist/jars/emr-checklist_2.10-0.1.0.jar oss://emr/checklist/data/wc oss://emr/checklist/data/wc-counts 32
          Important The JAR file is stored in Object Storage Service (OSS). To reference this file, use the path ossref://emr/checklist/jars/emr-checklist_2.10-0.1.0.jar. You can click + Insert OSS Path below, set file prefix to OSSREF, and use File Path to select your file. The system automatically fills in the OSS path of the Spark script.
      • Create a PySpark job.
        In addition to Scala or Java jobs, Alibaba Cloud E-MapReduce also supports Python-based Spark jobs. The following example shows the application parameters for a Python script named Python-Kmeans:
        --master yarn-client --driver-memory 7g --num-executors 10 --executor-memory 5g --executor-cores 1 ossref://emr/checklist/python/kmeans.py oss://emr/checklist/data/kddb 5 32
        Important
        • The ossref protocol is also used to reference Python script resources.
        • PySpark does not support installing Python packages as part of a job.
    2. Click Save.