Get the App
SLTechnology News&Howtos  ›  Development  › 

Two ways of submitting tasks in yarn mode in Spark

Shulou Source: shulou.com Published: 2022-06-03 14:21:41 09月30日 Update

This article mainly introduces "two ways of submitting tasks in yarn mode in Spark". In daily operation, I believe that many people have doubts about the two ways of submitting tasks in yarn mode in Spark. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "two ways of submitting tasks in yarn mode in Spark". Next, please follow the editor to study!

How 1.yarn-client submits tasks

Configuration

Add the Hadoop_HOME configuration directory to the client node configuration to submit the yarn task. The specific steps are as follows:

Export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop

one

Note that client only needs the installation package of Spark to submit tasks, and no other configuration (such as slaves) is required!

Submit command

/ opt/spark/bin/spark-submit-master yarn--class org.apache.spark.examples.SparkPi / opt/spark/examples/jars/spark-examples_2.11-2.2.0.jar 100/opt/spark/bin/spark-submit-- master yarn-client-- class org.apache.spark.examples.SparkPi / opt/spark/examples/jars/spark-examples_2.11-2.2.0.jar 100/opt/spark/bin/spark-submit- -master yarn-- deploy-mode client-- class org.apache.spark.examples.SparkPi / opt/spark/example

Execution process

-1. The client submits an Application and starts a Driver process on the client.

-the 2.Driver process sends a request to RS (ResourceManager) to start the resource of AM (ApplicationMaster).

-3.RS receives the request and randomly selects a NM (NodeManager) to launch AM. The NM here is equivalent to the Worker node in Standalone.

-after 4.AM starts, it requests a batch of container resources from RS to start Executor.

-5.RS will find a batch of NM and return it to AM to start Executor.

-6.AM sends a command to NM to start Executor.

-after 7.Executor starts, it will reverse register to Driver,Driver and send task to Executor, and the execution and result will be returned to the driver side.

Summary

1.Yarn-client mode is also suitable for testing, because Driver runs locally, Driver will communicate a lot with Executor in yarn cluster, which will increase the traffic of client network card.

The role of 2.ApplicationMaster:

Request resources for the current Application

Send a message to NodeManager to start Executor.

Note: ApplicationMaster has the ability to launchExecutor and request resources, but not job scheduling.

How 2.yarn-cluster submits tasks

Submit command

/ opt/spark/bin/spark-submit-master yarn--deploy-mode cluster-class org.apache.spark.examples.SparkPi / opt/spark/examples/jars/spark-examples_2.11-2.2.0.jar 100/opt/spark/bin/spark-submit-master yarn-cluster-class org.apache.spark.examples.SparkPi / opt/spark/examples/jars/spark-examples_2.11-2.2.0.jar 100

The result is in yarn's log:

At this point, the study on "two ways of submitting tasks in yarn mode in Spark" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Task mode mode resource learning configuration command client function client more result node process help utility next function client situation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple vpn Linux MySQL Docker