spark-submit 可以提交任务到 spark 集群执行,也可以提交到 hadoop 的 yarn 集群执行。
./bin/spark-submit \
--master spark://localhost:7077 \
examples/src/main/python/pi.py
spark 必须编译成支持 yarn 模式,编译 spark 的命令
build/mvn -Pyarn -Phadoop-2.x -Dhadoop.version=2.x.x -DskipTests clean package
编译完成后,提交任务到 hadoop yarn 集群执行
./bin/spark-submit
--class org.apache.spark.examples.SparkPi \
--master yarn \
--deploy-mode cluster \
--driver-memory 1g \
--executor-memory 1g \
--executor-cores 1 \
--queue thequeue \
examples/target/scala-2.11/jars/spark-examples*.jar 10
spark-submit 详细参数说明
| 参数名 | 参数说明 |
|---|---|
| -master | master 的地址,提交任务到哪里执行,例如 spark://host:port, yarn, local |
| -deploy-mode | 在本地 (client) 启动 driver 或在 cluster 上启动,默认是 client |
| -num-executors | 启动的 executor 数量。默认为2。在 yarn 下使用 |
| -driver-memory | Driver内存,默认 1G |
| -executor-memory | 每个 executor 的内存,默认是1G |
| -executor-core | 每个 executor 的核数。在yarn或者standalone下使用 |
| -name | 应用程序的名称 |
| -conf PROP=VALUE | 指定 spark 配置属性的值,例如 -conf spark.executor.extraJavaOptions="-XX:MaxPermSize=256m" |
| -class | 应用程序的主类,仅针对 java 或 scala 应用 |
| -jars | 用逗号分隔的本地 jar 包,设置后,这些 jar 将包含在 driver 和 executor 的 classpath 下 |
| -packages | 包含在driver 和executor 的 classpath 中的 jar 的 maven 坐标 |
| -exclude-packages | 为了避免冲突 而指定不包含的 package |
| -repositories | 远程 repository |
| -properties-file | 加载的配置文件,默认为 conf/spark-defaults.conf |
| -driver-java-options | 传给 driver 的额外的 Java 选项 |
| -driver-library-path | 传给 driver 的额外的库路径 |
| -driver-class-path | 传给 driver 的额外的类路径 |
| -driver-cores | Driver 的核数,默认是1。在 yarn 或者 standalone 下使用 |
| -total-executor-cores | 所有 executor 总共的核数。仅仅在 mesos 或者 standalone 下使用 |
博客介绍了 spark-submit 的功能,它可将任务提交到 spark 集群或 hadoop 的 yarn 集群执行。还提到 spark 需编译成支持 yarn 模式,并给出编译命令,最后对 spark-submit 的详细参数进行说明。


被折叠的 条评论
为什么被折叠?



