-
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 21 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 |
|---|---|---|
|
|
@@ -63,5 +63,7 @@ You can also run the unit-tests for SparkR by running (you need to install the [ | |
| The `./bin/spark-submit` and `./bin/sparkR` can also be used to submit jobs to YARN clusters. You will need to set YARN conf dir before doing so. For example on CDH you can run | ||
| ``` | ||
| export YARN_CONF_DIR=/etc/hadoop/conf | ||
| ./bin/spark-submit --master yarn --deploy-mode cluster (or client) examples/src/main/r/dataframe.R | ||
| OR | ||
|
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. Here, I'd prefer showing just your new example where |
||
| ./bin/spark-submit --master yarn examples/src/main/r/dataframe.R | ||
| ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,8 +58,8 @@ To run one of them, use `./bin/run-example <class> [params]`. For example: | |
| will run the Pi example locally. | ||
|
|
||
| You can set the MASTER environment variable when running examples to submit | ||
| examples to a cluster. This can be a mesos:// or spark:// URL, | ||
| "yarn-cluster" or "yarn-client" to run on YARN, and "local" to run | ||
| examples to a cluster. This can be a mesos:// or spark:// URL, to run on YARN; either --master yarn and set --deploy-mode (cluster or client) or simply set --master as | ||
|
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. The sentence doesn't quite work now; I think it has to be: "... spark:// URL, "yarn" to run on YARN, or "local" ..." In this high-level README it's not necessary to explain the alternative again. None of the alternatives are explained here in full. |
||
| "yarn-cluster" or "yarn-client", and "local" to run | ||
| locally with one thread, or "local[N]" to run locally with N threads. You | ||
| can also use an abbreviated class name if the class is in the `examples` | ||
| package. For instance: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,32 +21,51 @@ There are two deploy modes that can be used to launch Spark applications on 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: | ||
|
|
||
| `$ ./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 yarn-client/yarn-cluster [options] <app jar> [app options]` | ||
|
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 you have to change the explanation in the previous paragraph to explain the two YARN flag alternatives? that's the really key place. This example should only use cluster mode then, since that's what it says it does. It is not runnable like this.
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. also, this line looks wrong. The deploy mode takes in |
||
|
|
||
| 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 | ||
|
|
||
| `--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. As per above, explain this before the examples not after (and, nit, you can backtick-quote keywords) |
||
|
|
||
| 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 `yarn-client` mode, do the same, but replace `yarn-cluster` with `yarn-client`. To run spark-shell: | ||
| To launch a Spark application in `yarn-client` mode, do the same, but replace `yarn-cluster` with `yarn-client` in the --deploy-mode. To run spark-shell: | ||
|
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 is wrong; the values aren't |
||
|
|
||
| $ ./bin/spark-shell --master yarn-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 |
||
|
|
||
| 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 | ||
|
|
||
| `--master` can be `yarn-client` or `yarn-cluster` | ||
|
|
||
| ## 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 +405,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 `--master yarn --deploy-mode 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 would call the mode "YARN cluster" and "YARN client" mode consistently when not actually referring to the flags used to specify them. |
||
| - 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. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,6 +87,12 @@ run it with `--help`. Here are a few examples of common options: | |
| --total-executor-cores 100 \ | ||
| /path/to/examples.jar \ | ||
| 1000 | ||
|
|
||
| # Run a Python application on a Spark Standalone 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. Why move? |
||
| ./bin/spark-submit \ | ||
| --master spark://207.184.161.138:7077 \ | ||
| examples/src/main/python/pi.py \ | ||
| 1000 | ||
|
|
||
| # Run on a Spark Standalone cluster in cluster deploy mode with supervise | ||
| ./bin/spark-submit \ | ||
|
|
@@ -99,7 +105,7 @@ run it with `--help`. Here are a few examples of common options: | |
| /path/to/examples.jar \ | ||
| 1000 | ||
|
|
||
| # Run on a YARN cluster | ||
| # Run on a YARN cluster without --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. Same -- name was fine here. This needs to use |
||
| export HADOOP_CONF_DIR=XXX | ||
| ./bin/spark-submit \ | ||
| --class org.apache.spark.examples.SparkPi \ | ||
|
|
@@ -108,12 +114,6 @@ export HADOOP_CONF_DIR=XXX | |
| --num-executors 50 \ | ||
| /path/to/examples.jar \ | ||
| 1000 | ||
|
|
||
| # Run a Python application on a Spark Standalone cluster | ||
| ./bin/spark-submit \ | ||
| --master spark://207.184.161.138:7077 \ | ||
| examples/src/main/python/pi.py \ | ||
| 1000 | ||
| {% endhighlight %} | ||
|
|
||
| # Master URLs | ||
|
|
@@ -140,7 +140,6 @@ cluster mode. The cluster location will be found based on the HADOOP_CONF_DIR or | |
| </td></tr> | ||
| </table> | ||
|
|
||
|
|
||
| # Loading Configuration from a File | ||
|
|
||
| The `spark-submit` script can load default [Spark configuration values](configuration.html) from a | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -967,7 +967,7 @@ object Client extends Logging { | |
| def main(argStrings: Array[String]) { | ||
| if (!sys.props.contains("SPARK_SUBMIT")) { | ||
| logWarning("WARNING: This client is deprecated and will be removed in a " + | ||
| "future version of Spark. Use ./bin/spark-submit with \"--master yarn\"") | ||
| "future version of Spark. Use ./bin/spark-submit with \"--master yarn --deploy-mode cluster (or client) OR --master yarn-cluster (yarn-client)\"") | ||
|
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 this was OK; the purpose of the message is just to refer to YARN mode in general. It doesn't have to explain the options again. |
||
| } | ||
|
|
||
| // Set an env variable indicating we are running in YARN mode. | ||
|
|
||
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.
Since this is intended as a runnable snippet, I don't think you can write "cluster (or client)". I'd write "client". Elsewhere it's explained what this option's values are.