Spark 提交 job 流程
由于提交流程相对很抽象,笔者决定先从提交脚本中的常用参数讲起,再讲解提交流程的过程。
1.提交脚本中的参数解析
笔者项目使用的Spark版本为Spark-2.0.2。下图是笔者项目中实际提交Spark Streaming任务时所使用的提交脚本。具体任务相关的信息抹去了,那么本文就从该脚本中的参数配置讲起。
spark-submit \
--master yarn \ 运行的模式
--deploy-mode cluster \
--name spark-test \ 在yarn界面看到的名字,如果不设置,那就是下面--class的值
--driver-memory 1g \ driver的内存
--executor-memory 1g \ 每一个executor的内存
--executor-cores 1 \ executor数量
--jars xxx.jar, xxx.jar, xxx.jar 第三方jar,比如hbase,flume、apache的一些工具jar
--conf 设置spark内定的参数
--files /conf.properties \ 发送到集群的配置文件,可以直接new fileInputstream("conf.properties")来获取
--class WordCount \ 主类
/WordCount-20210702-1.0.0.jar \ 自己工程的jar
1.1 常用参数含义
spark-submit --help查看解释
$ bin/spark-submit --help
Usage: spark-submit [options] <app jar | python file> [app arguments]
Usage: spark-submit --kill [submission ID] --master [spark://...]
Usage: spark-submit --status [submission ID] --master [spark://...]
Options:
--master MASTER_URL spark://host:port, mesos://host:port, yarn, or local.
--deploy-mode DEPLOY_MODE Whether to launch the driver program locally ("client") or
on one of the worker machines inside the cluster ("cluster")
(Default: client).
-