spark-submit命令

(集群模式)限制资源,资源不足时候会卡在分配资源(–total-executor-cores 和 –executor-cores为总数和单点cores数量)

spark-submit --class test.Streamings --master spark://192.168.3.74:7077 --deploy-mode cluster --executor-memory 1024M --total-executor-cores 5 sparkdemo-0.0.1.jar

(集群模式)控制台输出(不限制资源),可用于调试

spark-submit --class test.Streamings --master spark://192.168.3.74:7077 sparkdemo-0.0.1.jar

(集群模式)控制台无输出(不限制资源),提交任务,最大资源分配

spark-submit --class test.Streamings --master spark://192.168.3.74:7077 --deploy-mode cluster sparkdemo-0.0.1.jar

(单点模式)控制台输出

spark-submit --class test.Streamings sparkdemo-0.0.1.jar

官方附言

spark-submit –help

操作

解析

–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).在本地还是在集群内的某个工作机器上启动驱动程序,默认本地。

–class CLASS_NAME

Your application’s main class (for Java / Scala apps).app的入口类

–name NAME

A name of your application.app名称

–jars JARS

Comma-separated list of local jars to include on the driver and executor classpaths.多个jar用逗号分隔

–packages

Comma-separated list of maven coordinates of jars to include on the driver and executor classpaths. Will search the local maven repo, then maven central and any additional remote repositories given by –repositories. The format for the coordinates should be groupId:artifactId:version.提供groupId:artifactId:version形式的maven库的jar包依赖,逗号分隔

–exclude-packages

Comma-separated list of groupId:artifactId, to exclude while resolving the dependencies provided in –packages to avoid dependency conflicts.以逗号分隔的groupId:artifactId,以排除解析–packages中提供的依赖关系以避免依赖冲突。

–repositories

Comma-separated list of additional remote repositories to search for the maven coordinates given with –packages.

–py-files PY_FILES

Comma-separated list of .zip, .egg, or .py files to place on the PYTHONPATH for Python apps.用于Python应用程序的PYTHONPATH上的.zip,.egg或.py文件的逗号分隔列表。

–files FILES

Comma-separated list of files to be placed in the working directory of each executor.逗号分隔的文件列表

–conf PROP=VALUE

Arbitrary Spark configuration property.任意Spark配置属性。

–properties-file FILE

Path to a file from which to load extra properties. If not specified, this will look for conf/spark-defaults.conf.指向要从其加载额外属性的文件的路径。 如果没有指定,这将寻找conf/spark-defaults.conf。

–driver-memory MEM

Memory for driver (e.g. 1000M, 2G) (Default: 1024M).设置driver内存大小

–driver-java-options

Extra Java options to pass to the driver.额外的Java选项给driver。

–driver-library-path

Extra library path entries to pass to the driver.额外的库路径给driver。

–driver-class-path

Extra class path entries to pass to the driver. Note that jars added with –jars are automatically included in the classpath.额外的类路径给driver。注意添加了 –jars 会自动包含在classpath下

–executor-memory MEM

Memory per executor (e.g. 1000M, 2G) (Default: 1G).每个执行器的内存大小

–proxy-user NAME

User to impersonate when submitting the application. This argument does not work with –principal / –keytab.用户在提交应用是代理。 这个参数不适用于–principal/–keytab。

–help, -h

Show this help message and exit.帮助

–verbose, -v

Print additional debug output.打印调试信息

–version,

Print the version of current Spark.输出版本


Spark standalone with cluster deploy mode only: 仅限Spark单机与群集部署模式

操作

解析

–driver-cores NUM

Cores for driver (Default: 1).driver 核数,默认1


Spark standalone or Mesos with cluster deploy mode only: 仅限Spark单机或Mesos与群集部署模式

操作

解析

–supervise

If given, restarts the driver on failure.如果给出,失败时重新启动驱动程序。

–kill SUBMISSION_ID

If given, kills the driver specified.如果给定,则会杀死指定的驱动程序。

–status SUBMISSION_ID

If given, requests the status of the driver specified.如果给出,请求指定的驱动程序的状态。


Spark standalone and Mesos only:仅限Spark单机和Mesos

操作

解析

–total-executor-cores NUM

Total cores for all executors.所有执行器的核心总数。


Spark standalone and YARN only:仅限Spark单机和YARN

操作

解析

–executor-cores NUM

Number of cores per executor. (Default: 1 in YARN mode, or all available cores on the worker in standalone mode) 每个执行器的核心数。 (默认值:YARN模式下为1,或单机模式下使用所有核)


YARN-only: 仅限YARN

操作

解析

–driver-cores NUM

Number of cores used by the driver, only in cluster mode (Default: 1).仅在集群下使用,driver的核心数量,默认1

–queue QUEUE_NAME

The YARN queue to submit to (Default: “default”).YARN队列名,默认叫default

–num-executors NUM

Number of executors to launch (Default: 2). If dynamic allocation is enabled, the initial number of executors will be at least NUM. 要启动的执行器数(默认值:2)。 如果启用动态分配,则初始执行者数将至少为NUM。

–archives ARCHIVES

Comma separated list of archives to be extracted into the working directory of each executor.逗号分隔的目录列表

–principal PRINCIPAL

Principal to be used to login to KDC, while running on secure HDFS.

–keytab KEYTAB

The full path to the file that contains the keytab for the principal specified above. This keytab will be copied to the node running the Application Master via the Secure Distributed Cache, for renewing the login tickets and the delegation tokens periodically.