Help Center > > User Guide> Managing Active Clusters> Managing Jobs> Running a SparkSql Job

Running a SparkSql Job

Updated at: Apr 28, 2020 GMT+08:00

You can submit programs developed by yourself to MRS to execute them, and obtain the results. This section describes how to submit a SparkSql job on the MRS management console. SparkSql jobs are used for data query and analysis. Both SQL statements and scripts are supported. If SQL statements contain sensitive information, use Spark Script to submit them.

Prerequisites

You have uploaded the program packages and data files required for running jobs to OBS or HDFS.

Submitting a Job on the GUI

  1. Log in to the MRS management console.
  2. Choose Clusters > Active Clusters, select a running cluster, and click its name to switch to the cluster details page.
  3. If Kerberos authentication is enabled for the cluster, perform the following steps. If Kerberos authentication is not enabled for the cluster, skip this step.

    In the Basic Information area on the Dashboard tab page, click on the right side of IAM User Sync to synchronize IAM users. For details, see Synchronizing IAM Users to MRS.

    • In MRS 2.0.1 or versions earlier than MRS 1.8.7, the job management function is unavailable in a cluster with Kerberos authentication enabled. You need to submit a job in the background.
    • When the policy of the user group to which the IAM user belongs changes from MRS ReadOnlyAccess to MRS CommonOperations, MRS FullAccess, or MRS Administrator, wait for 5 minutes until the new policy takes effect after the synchronization is complete because the sssd cache of cluster nodes needs time to be updated. Then, submit a job. Otherwise, the job may fail to be submitted.
    • When the policy of the user group to which the IAM user belongs changes from MRS CommonOperations, MRS FullAccess, or MRS Administrator to MRS ReadOnlyAccess, wait for 5 minutes until the new policy takes effect after the synchronization is complete because the sssd cache of cluster nodes needs time to be updated.

  4. Click the Jobs tab.
  5. If the cluster version is MRS 1.8.7, MRS 1.8.10, MRS 1.9.2, or later than MRS 2.0.1, perform the following operations: Click Create. On the displayed Create Job page, set Type to SparkSql and configure SparkSql job information by referring to Table 1.

    Table 1 Job configuration information

    Parameter

    Description

    Name

    Job name. It contains 1 to 64 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed.

    NOTE:

    You are advised to set different names for different jobs.

    SQL Type

    Submission type of the SQL statement

    • SQL
    • Script

    SQL Statement

    This parameter is valid only when SQL Type is set to SQL. Enter the SQL statement to be executed, and then click Check to check whether the SQL statement is correct. If you want to submit and execute multiple statements at the same time, use semicolons (;) to separate them.

    SQL File

    This parameter is valid only when SQL Type is set to Script. The path of the SQL file to be executed must meet the following requirements:

    • Contains a maximum of 1,023 characters, excluding special characters such as ;|&><'$. The parameter value cannot be empty or full of spaces.
    • The path of the program to be executed can be stored in HDFS or OBS. The path varies depending on the file system.
      • OBS: The path must start with s3a://. Example: s3a://wordcount/program/xxx.jar
      • OBS: The path must start with obs://. Example: obs://wordcount/program/xxx.jar (supported in MRS 2.0.5 or later)
      • HDFS: The path must start with /user.
    • For SparkScript and HiveScript, the path must end with .sql. For MapReduce, the path must end with .jar. For Flink and SparkSubmit, the path must end with .jar or .py. The .sql, .jar, and .py are case-insensitive.
    NOTE:

    For MRS 2.0.5 or later: A file path on OBS can start with obs://. To submit jobs in this format, you need to configure permissions for accessing OBS.

    • If the OBS permission control function is enabled during cluster creation, you can use the obs:// directory without extra configuration.
    • If the OBS permission control function is not enabled or is not supported (supported in MRS 2.0.3 or later) when you create a cluster, configure the function by following instructions in Accessing OBS.

    Program Parameter

    Used to configure optimization parameters such as threads, memory, and vCPUs for the job to optimize resource usage and improve job execution performance.

    Service Parameter

    This parameter is optional. It is used to modify service parameters for the job. The parameter modification applies only to the current job. To make the modification take effect permanently for the cluster, follow instructions in Configuring Service Parameters.

    To add multiple parameters, click on the right. To delete a parameter, click Delete on the right.

    Command Reference

    Command submitted to the background for execution when a job is submitted

  6. If the cluster version is MRS 2.0.1 or earlier than MRS 1.8.7, perform the following operations to create Spark Script and Spark SQL jobs:

    • Spark Script job: On the Jobs tab page, click Create. On the displayed Create Job page, set Type to Spark Script and configure job information by referring to Table 2.
    • Spark SQL job: Click the Spark SQL tab, add SQL statements, and submit the SQL statements after a check.
      Table 2 Job configuration information

      Parameter

      Description

      Name

      Job name. It contains 1 to 64 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed.

      NOTE:

      You are advised to set different names for different jobs.

      Program Path

      Path of the program package to be executed. The following requirements must be met:

      • Contains a maximum of 1,023 characters, excluding special characters such as ;|&><'$. The parameter value cannot be empty or full of spaces.
      • The path of the program to be executed can be stored in HDFS or OBS. The path varies depending on the file system.
        • OBS: The path must start with s3a://. Example: s3a://wordcount/program/xxx.jar
        • HDFS: The path must start with /user.
      • For SparkScript, the path must end with .sql. For MapReduce and Spark, the path must end with .jar. The .sql and .jar are case-insensitive.

      Parameters

      Key parameter for program execution. The parameter is specified by the function of the user's program. MRS is only responsible for loading the parameter. Multiple parameters are separated by space.

      Configuration method: Package name.Class name

      The parameter contains a maximum of 2,047 characters, excluding special characters such as ;|&><'$, and can be left blank.

      NOTE:

      When entering a parameter containing sensitive information (for example, login password), you can add an at sign (@) before the parameter name to encrypt the parameter value. This prevents the sensitive information from being persisted in plaintext. When you view job information on the MRS management console, the sensitive information is displayed as *.

      Example: username=admin @password=admin_123

      Import from

      Path for inputting data

      Data can be stored in HDFS or OBS. The path varies depending on the file system.
      • OBS: The path must start with s3a://.
      • HDFS: The path must start with /user.

      The parameter contains a maximum of 1,023 characters, excluding special characters such as ;|&>,<'$, and can be left blank.

      Export to

      Path for outputting data

      NOTE:
      • When setting this parameter, select OBS or HDFS. Select a file directory or manually enter a file directory, and click OK.
      • If you add the hadoop-mapreduce-examples-x.x.x.jar sample program or a program similar to hadoop-mapreduce-examples-x.x.x.jar, enter a directory that does not exist.
      Data can be stored in HDFS or OBS. The path varies depending on the file system.
      • OBS: The path must start with s3a://.
      • HDFS: The path must start with /user.

      The parameter contains a maximum of 1,023 characters, excluding special characters such as ;|&>,<'$, and can be left blank.

      Log Path

      Path for storing job logs that record job running status.

      Data can be stored in HDFS or OBS. The path varies depending on the file system.
      • OBS: The path must start with s3a://.
      • HDFS: The path must start with /user.

      The parameter contains a maximum of 1,023 characters, excluding special characters such as ;|&>,<'$, and can be left blank.

  7. Confirm job configuration information and click OK.

    After the job is created, you can manage it.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel