【甘道夫】Spark1.3.0 Submitting Applications 官方文档精华摘要,spark1.3


引言 由于工作需要,即将拥抱Spark,曾经进行过相关知识的学习,现在计划详细读一遍最新版本Spark1.3的部分官方文档,一是复习,二是了解最新进展,三是为公司团队培训做储备。
欢迎转载,请注明出处: http://blog.csdn.net/u010967382/article/details/45062381

原文URL:http://spark.apache.org/docs/latest/submitting-applications.html 该文档重点介绍如何将编写好的Spark应用程序提交到Spark集群中运行。
首先需要将应用程序的所有依赖都打包到应用程序jar中。 注意,无需将Spark和Hadoop作为依赖包加入集合jar中,因为在运行时Cluster Manager会提供这些系统级的依赖。
一旦程序打包好了,就可以通过bin/spark-submit脚本将应用程序提交给Spark集群。

bin/spark-submit脚本格式如下:
./bin/spark-submit \   --class <main-class>   --master <master-url> \   --deploy-mode <deploy-mode> \   --conf <key>=<value> \   ... # other options   <application-jar> \   [application-arguments]
一些常用的选项包括:
  • --class: 应用程序的入口类,包含main方法;
  • --master: 集群中Master节点的URL(e.g. spark://23.195.26.187:7077) ,该参数一言难尽,后面有详细说明;
  • --deploy-mode决定你的driver程序的运行位置,cluster模式是运行在worker节点上,client模式是运行在集群外部。默认是client模式;
  • --conf: 任意Spark的基础属性配置,用key=value格式;
  • application-jar: 指向应用程序jar包的路径,路径必须全局可见,要么是一个hdfs路径,要么是一个所有node本地都有的文件路径
  • application-arguments: 应用程序接收的参数。

关于--deploy-mode参数
  • client模式:一个常见的部署策略是从一台网关机器提交你的应用程序,这台机器和你的worker机器物理上很接近(例如集群中的Master节点)。在这样的场景下,client模式就非常适合。在client模式中,driver程序直接在spark-submit进程中启动,spark-submit进程对于集群来说就是一个客户端程序。应用程序的输入和输出都会通过控制台。这样的话,client模式就尤其适合包含REPL(“读取-求值-输出”循环,英语:Read-Eval-Print Loop,简称REPL)的应用程序,比如Spark shell
  • cluster模式:另一个经典场景,cluster模式,如果你的应用程序从一台离workder机器较远的机器提交(例如从你的笔记本电脑上提交),通常会通过cluster模式来最小化driver和executors之间的网络延迟。注意,cluster模式现在尚未支持Mesos集群或者Python应用程序。

关于--master参数
Master URL Meaning
local Run Spark locally with one worker thread (i.e. no parallelism at all).
local[K] Run Spark locally with K worker threads (ideally, set this to the number of cores on your machine).
local[*] Run Spark locally with as many worker threads as logical cores on your machine.
spark://HOST:PORT Connect to the given Spark standalone cluster master. The port must be whichever one your master is configured to use, which is 7077 by default.
mesos://HOST:PORT Connect to the given Mesos cluster. The port must be whichever one your is configured to use, which is 5050 by default. Or, for a Mesos cluster using ZooKeeper, use mesos://zk://....
yarn-client Connect to a YARN cluster in client mode. 
The cluster location will be found based on the HADOOP_CONF_DIR variable.
yarn-cluster Connect to a YARN cluster in cluster mode. 
The cluster location will be found based on HADOOP_CONF_DIR.

spark-submit脚本默认读取conf/spark-defaults.conf中的配置属性,我们可以在conf/spark-defaults.conf文件中做好基础属性的配置,就无需在spark-submit脚本中重复指定了,例如,如果spark.master属性已经设置了,你就可以不用在调用spark-submit脚本时再次传入spark.master参数。

相关内容

    暂无相关文章