-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-9570][Docs][YARN]Consistent recommendation for submitting spark apps to YARN, -master yarn --deploy-mode x vs -master yarn-x' #8385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 27 commits
fa93415
437a4d4
05fe708
98624e8
b8fdd5c
8c65676
8a331d0
0fed23b
670d251
40d3b80
89d15bf
d2c212a
3f25500
0766da6
46a24d5
9175807
3052c74
c91073e
3dc79e2
67a4255
a8b67ef
d93d4ba
108caec
12ecd43
0cd5d0b
07ed32c
1b86c35
9be5993
177146e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,37 +16,54 @@ containers used by the application use the same configuration. If the configurat | |
| Java system properties or environment variables not managed by YARN, they should also be set in the | ||
| Spark application's configuration (driver, executors, and the AM when running in client mode). | ||
|
|
||
| There are two deploy modes that can be used to launch Spark applications on YARN. In `yarn-cluster` mode, the Spark driver runs inside an application master process which is managed by YARN on the cluster, and the client can go away after initiating the application. In `yarn-client` mode, the driver runs in the client process, and the application master is only used for requesting resources from YARN. | ||
| There are two deploy modes that can be used to launch Spark applications on YARN. In `cluster` mode, the Spark driver runs inside an application master process which is managed by YARN on the cluster, and the client can go away after initiating the application. In `client` mode, the driver runs in the client process, and the application master is only used for requesting resources from YARN. | ||
|
|
||
| Unlike in Spark standalone and Mesos mode, in which the master's address is specified in the `--master` parameter, in YARN mode the ResourceManager's address is picked up from the Hadoop configuration. Thus, the `--master` parameter is `yarn-client` or `yarn-cluster`. | ||
| To launch a Spark application in `yarn-cluster` mode: | ||
| Unlike in Spark standalone and Mesos mode, in which the master's address is specified in the `--master` parameter, in YARN mode the ResourceManager's address is picked up from the Hadoop configuration. Thus, the `--master` parameter is `yarn` and to specify the deployment `--deploy-mode` can be either `client` or `cluster`. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might need different wording: "... and |
||
| To launch a Spark application in YARN in `cluster` mode: | ||
|
|
||
| `$ ./bin/spark-submit --class path.to.your.Class --master yarn-cluster [options] <app jar> [app options]` | ||
| `$ ./bin/spark-submit --class path.to.your.Class --master yarn --deploy-mode cluster [options] <app jar> [app options]` | ||
|
|
||
| For example: | ||
|
|
||
| $ ./bin/spark-submit --class org.apache.spark.examples.SparkPi \ | ||
| --master yarn-cluster \ | ||
| --master yarn \ | ||
| --deploy-mode cluster | ||
| --num-executors 3 \ | ||
| --driver-memory 4g \ | ||
| --executor-memory 2g \ | ||
| --executor-cores 1 \ | ||
| --queue thequeue \ | ||
| lib/spark-examples*.jar \ | ||
| 10 | ||
|
|
||
| The above starts a YARN client program which starts the default Application Master. Then SparkPi will be run as a child thread of Application Master. The client will periodically poll the Application Master for status updates and display them in the console. The client will exit once your application has finished running. Refer to the "Debugging your Application" section below for how to see driver and executor logs. | ||
| The above example starts a YARN client program which starts the default Application Master. Then SparkPi will be run as a child thread of Application Master. The client will periodically poll the Application Master for status updates and display them in the console. The client will exit once your application has finished running. Refer to the "Debugging your Application" section below for how to see driver and executor logs. | ||
|
|
||
| To launch a Spark application in `client` mode, do the same, but replace `cluster` with `client` in the --deploy-mode. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "in the |
||
| To run spark-shell: | ||
|
|
||
| To launch a Spark application in `yarn-client` mode, do the same, but replace `yarn-cluster` with `yarn-client`. To run spark-shell: | ||
| $ ./bin/spark-shell --master yarn --deploy-mode client | ||
|
|
||
| The alternative to launching a Spark application on YARN is to set deployment mode for the YARN master in the `--master` itself. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes that's right; I'd suggest slightly different wording. Spark also supports
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I'd suggest that we don't even document this anymore. New users should use the normal notation instead of
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It sounds like we don't even need to cover the original |
||
| `--master` can be `yarn-client` or `yarn-cluster` | ||
|
|
||
| $ ./bin/spark-shell --master yarn-client | ||
| For example: | ||
|
|
||
| $ ./bin/spark-submit --class org.apache.spark.examples.SparkPi \ | ||
| --master yarn-cluster \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. still using yarn-cluster instead of deploy-mode |
||
| --num-executors 3 \ | ||
| --driver-memory 4g \ | ||
| --executor-memory 2g \ | ||
| --executor-cores 1 \ | ||
| --queue thequeue \ | ||
| lib/spark-examples*.jar \ | ||
| 10 | ||
|
|
||
| ## Adding Other JARs | ||
|
|
||
| In `yarn-cluster` mode, the driver runs on a different machine than the client, so `SparkContext.addJar` won't work out of the box with files that are local to the client. To make files on the client available to `SparkContext.addJar`, include them with the `--jars` option in the launch command. | ||
|
|
||
| $ ./bin/spark-submit --class my.main.Class \ | ||
| --master yarn-cluster \ | ||
| --master yarn | ||
| --deploy-mode cluster \ | ||
| --jars my-other-jar.jar,my-other-other-jar.jar | ||
| my-main-jar.jar | ||
| app_arg1 app_arg2 | ||
|
|
@@ -386,6 +403,6 @@ If you need a reference to the proper location to put log files in the YARN so t | |
| # Important notes | ||
|
|
||
| - Whether core requests are honored in scheduling decisions depends on which scheduler is in use and how it is configured. | ||
| - In `yarn-cluster` mode, the local directories used by the Spark executors and the Spark driver will be the local directories configured for YARN (Hadoop YARN config `yarn.nodemanager.local-dirs`). If the user specifies `spark.local.dir`, it will be ignored. In `yarn-client` mode, the Spark executors will use the local directories configured for YARN while the Spark driver will use those defined in `spark.local.dir`. This is because the Spark driver does not run on the YARN cluster in `yarn-client` mode, only the Spark executors do. | ||
| - In `yarn-cluster`, the local directories used by the Spark executors and the Spark driver will be the local directories configured for YARN (Hadoop YARN config `yarn.nodemanager.local-dirs`). If the user specifies `spark.local.dir`, it will be ignored. In `yarn-client` mode, the Spark executors will use the local directories configured for YARN while the Spark driver will use those defined in `spark.local.dir`. This is because the Spark driver does not run on the YARN cluster in `yarn-client` mode, only the Spark executors do. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to just call this "YARN cluster" and "YARN client" mode if not referring to the arguments. |
||
| - The `--files` and `--archives` options support specifying file names with the # similar to Hadoop. For example you can specify: `--files localtest.txt#appSees.txt` and this will upload the file you have locally named localtest.txt into HDFS but this will be linked to by the name `appSees.txt`, and your application should use the name as `appSees.txt` to reference it when running on YARN. | ||
| - The `--jars` option allows the `SparkContext.addJar` function to work if you are using it with local files and running in `yarn-cluster` mode. It does not need to be used if you are using it with HDFS, HTTP, HTTPS, or FTP files. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1551,7 +1551,7 @@ on all of the worker nodes, as they will need access to the Hive serialization a | |
| (SerDes) in order to access data stored in Hive. | ||
|
|
||
| Configuration of Hive is done by placing your `hive-site.xml` file in `conf/`. Please note when running | ||
| the query on a YARN cluster (`yarn-cluster` mode), the `datanucleus` jars under the `lib_managed/jars` directory | ||
| the query on a YARN cluster (`--master yarn --deploy-mode cluster` mode), the `datanucleus` jars under the `lib_managed/jars` directory | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, would just omit this parenthetical comment |
||
| and `hive-site.xml` under `conf/` directory need to be available on the driver and all executors launched by the | ||
| YARN cluster. The convenient way to do this is adding them through the `--jars` option and `--file` option of the | ||
| `spark-submit` command. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, I'd prefer showing just your new example where
deploy-modeis explicit. Might as well set a good example.