不多说,直接上干货!

 spark-submit在哪个位置

[spark@master ~]$ cd $SPARK_HOME/bin
[spark@master bin]$ pwd
/usr/local/spark/spark-1.6.-bin-hadoop2./bin
[spark@master bin]$ ll
total
-rwxr-xr-x. spark spark Feb beeline
-rw-r--r--. spark spark Feb beeline.cmd
-rw-r--r--. spark spark Feb load-spark-env.cmd
-rw-r--r--. spark spark Feb load-spark-env.sh
-rwxr-xr-x. spark spark Feb pyspark
-rw-r--r--. spark spark Feb pyspark2.cmd
-rw-r--r--. spark spark Feb pyspark.cmd
-rwxr-xr-x. spark spark Feb run-example
-rw-r--r--. spark spark Feb run-example2.cmd
-rw-r--r--. spark spark Feb run-example.cmd
-rwxr-xr-x. spark spark Feb spark-class
-rw-r--r--. spark spark Feb spark-class2.cmd
-rw-r--r--. spark spark Feb spark-class.cmd
-rwxr-xr-x. spark spark Feb sparkR
-rw-r--r--. spark spark Feb sparkR2.cmd
-rw-r--r--. spark spark Feb sparkR.cmd
-rwxr-xr-x. spark spark Feb spark-shell
-rw-r--r--. spark spark Feb spark-shell2.cmd
-rw-r--r--. spark spark Feb spark-shell.cmd
-rwxr-xr-x. spark spark Feb spark-sql
-rwxr-xr-x. spark spark Feb spark-submit
-rw-r--r--. spark spark Feb spark-submit2.cmd
-rw-r--r--. spark spark Feb spark-submit.cmd
[spark@master bin]$

打包Spark application

  将Spark application打成assemblyed jar。我们都知道,其实我们写好的一个Spark application,它除了spark本身的jar包和hdfs的jar包之外,它还有第三方其他的jar包对吧!所以,我们一般借助于maven或sbt的方式来打到最后的一个assemblyed jar。(同时,注意,只打包需要的依赖!!)

  构建工具:

    1.maven--maven-shade-plugin

    请移步,

Spark编程环境搭建(基于Intellij IDEA的Ultimate版本)(包含Java和Scala版的WordCount)(博主强烈推荐)

   

   2.sbt

     这种方式,我不多说。个人偏爱好maven。

   3、更多方式见

IDEA里如何多种方式打jar包,然后上传到集群

 

使用spark-submit启动Spark application

  $SPARK_HOME/bin/spark-submit \
  --class <main-class> \
  --master \
  --deploy-mode \
  --conf = \
  ... # other options \
  [application-arguments]

  请移步,见

Spark on YARN简介与运行wordcount(master、slave1和slave2)(博主推荐)

Spark standalone简介与运行wordcount(master、slave1和slave2)

spark-submit usage

  Usage: spark-submit [options] [app arguments]

  Usage: spark-submit --kill [submission ID] --master [spark://...]

  Usage: spark-submit --status [submission ID] --master [spark://...]

[spark@master ~]$ $SPARK_HOME/bin/spark-submit  

或者

[spark@master ~]$ $SPARK_HOME/bin/spark-submit --help

[spark@master ~]$ $SPARK_HOME/bin/spark-submit     或者     $SPARK_HOME/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).
--class CLASS_NAME Your application's main class (for Java / Scala apps).
--name NAME A name of your application.
--jars JARS Comma-separated list of local jars to include on the driver
and executor classpaths.
--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.
--exclude-packages Comma-separated list of groupId:artifactId, to exclude while
resolving the dependencies provided in --packages to avoid
dependency conflicts.
--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.
--files FILES Comma-separated list of files to be placed in the working
directory of each executor. --conf PROP=VALUE Arbitrary Spark configuration property.
--properties-file FILE Path to a file from which to load extra properties. If not
specified, this will look for conf/spark-defaults.conf.
--driver-memory MEM Memory for driver (e.g. 1000M, 2G) (Default: 1024M).
--driver-java-options Extra Java options to pass to the driver.
--driver-library-path Extra library path entries to pass to the 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. --executor-memory MEM Memory per executor (e.g. 1000M, 2G) (Default: 1G). --proxy-user NAME User to impersonate when submitting the application. --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:
--driver-cores NUM Cores for driver (Default: ). Spark standalone or Mesos with cluster deploy mode only:
--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:
--total-executor-cores NUM Total cores for all executors. Spark standalone and YARN only:
--executor-cores NUM Number of cores per executor. (Default: in YARN mode,
or all available cores on the worker in standalone mode) YARN-only:
--driver-cores NUM Number of cores used by the driver, only in cluster mode
(Default: ).
--queue QUEUE_NAME The YARN queue to submit to (Default: "default").
--num-executors NUM Number of executors to launch (Default: ).
--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. [spark@master ~]$

spark-submit option—运行模式相关

  设置Spark的运行模式,根据需求选择

  典型的Master URL:

          

      注意:--deploy-mode不是spark on yarn专有

  

  典型的Master URL:

        

spark-submit options—常规

        

spark-submit options—classpath相关、driver、executor相关

          

spark-submit options—资源、配置相关

          

spark-submit options—YARN-only

  以下options只有在Saprk on YARN模式下才有效

            

spark-submit options—其他

        

Advanced Dependency Management

  依赖包分发方式

    --jars

      1.file—绝对路径,file:/xxxx

       2.hdfs、http、https、ftp

      3.local

    --repositories、--packages

    --py-files(仅限python app)

  Clean up

    Jars和files会被拷贝到每个executor的工作目录,需要定期清理:

      Spark on yarn会自动清理(spark.yarn.preserve.staging.files设置为flase,默认就是false)

      Spark standalone(spark.worker.cleanup.appDataTtl)  

Spark应用程序部署工具Spark Submit的更多相关文章

  1. spark 应用程序部署工具 spark-submit

    打包 Spark application 使用spark-submit启动Spark application spark-submit usage spark-submit option 运行模式相关 ...

  2. Spark1.0.0 应用程序部署工具spark-submit

    原文链接:http://blog.csdn.net/book_mmicky/article/details/25714545 随着Spark的应用越来越广泛,对支持多资源管理器应用程序部署工具的需求也 ...

  3. Spark入门实战系列--2.Spark编译与部署(下)--Spark编译安装

    [注]该系列文章以及使用到安装包/测试数据 可以在<倾情大奉送--Spark入门实战系列>获取 .编译Spark .时间不一样,SBT是白天编译,Maven是深夜进行的,获取依赖包速度不同 ...

  4. 【Spark 深入学习 -09】Spark生态组件及Master节点HA

    ----本节内容------- 1.Spark背景介绍 2.Spark是什么 3.Spark有什么 4.Spark部署 4.1.Spark部署的2方面 4.2.Spark编译 4.3.Spark St ...

  5. Spark中文指南(入门篇)-Spark编程模型(一)

    前言 本章将对Spark做一个简单的介绍,更多教程请参考:Spark教程 本章知识点概括 Apache Spark简介 Spark的四种运行模式 Spark基于Standlone的运行流程 Spark ...

  6. 转载:Spark中文指南(入门篇)-Spark编程模型(一)

    原文:https://www.cnblogs.com/miqi1992/p/5621268.html 前言 本章将对Spark做一个简单的介绍,更多教程请参考:Spark教程 本章知识点概括 Apac ...

  7. 61、Spark Streaming:部署、升级和监控应用程序

    一.部署应用程序 1.流程 1.有一个集群资源管理器,比如standalone模式下的Spark集群,Yarn模式下的Yarn集群等. 2.打包应用程序为一个jar包. 3.为executor配置充足 ...

  8. Spark入门实战系列--2.Spark编译与部署(上)--基础环境搭建

    [注] 1.该系列文章以及使用到安装包/测试数据 可以在<倾情大奉送--Spark入门实战系列>获取: 2.Spark编译与部署将以CentOS 64位操作系统为基础,主要是考虑到实际应用 ...

  9. Spark入门实战系列--2.Spark编译与部署(中)--Hadoop编译安装

    [注]该系列文章以及使用到安装包/测试数据 可以在<倾情大奉送--Spark入门实战系列>获取 .编译Hadooop 1.1 搭建环境 1.1.1 安装并设置maven 1. 下载mave ...

随机推荐

  1. 【基础篇】DatePickerDialog日期控件的基本使用(二) ——分别获取年、月、日、时、分

    项目步骤: 1.在Main.xml布局文件中定义对应的组件,Main.xml内容如下: <?xml version="1.0" encoding="utf-8&qu ...

  2. LINUX中,find结合grep正则表达式,快速查找代码文件。

    ###目的###LINUX中,find结合grep正则表达式快速查找代码. 例如经常有需求:查找当前目录下所有.h文件中,"public开头,中间任意字符,以VideoFrameReceiv ...

  3. Vue常见面试题汇总

    Vue框架常见面试题   1.active-class是哪个组件的属性?嵌套路由怎么定义? 答:vue-router模块的router-link组件. 2.怎么定义vue-router的动态路由?怎么 ...

  4. idea中实现类快速重写service方法 快捷键

    1.在实现类中 CTRL+O 快捷键,会弹出所有方法 2.选择service中的方法,会自动重写

  5. Codeforces Beta Round #2 C. Commentator problem

    模拟退火果然是一个非常高端的东西,思路神马的全然搞不懂啊~ 题目大意: 给出三个圆,求一点到这三个圆的两切线的夹角相等. 解题思路: 对于这个题来说还是有多种思路的 .只是都搞不明确~~   /害羞脸 ...

  6. Android控件ToggleButton的使用方法

    ToggleButton(开关button)是Android系统中比較简单的一个组件,是一个具有选中和未选择状态双状态的button.而且须要为不同的状态设置不同的显示文本. ToggleButton ...

  7. [BZOJ2143]飞飞侠 并查集优化最短路

    链接 题解 首先很容易想到对每个点暴力跑Dijkstra,但是这样边数是 \(N^4\) 的,考虑优化 发现每次松弛的时候,都要把整个地图扫一遍,每个节点都要重复扫很多次,如果我们在一个点不会再被更新 ...

  8. Android图像处理之熔铸特效

    代码: package com.color; import android.content.Context; import android.graphics.Bitmap; import androi ...

  9. 39.Node.js域名解析---DNS模块

    转自:http://www.runoob.com/nodejs/nodejs-module-system.html Node.js DNS 模块用于解析域名.引入 DNS 模块语法格式如下: var ...

  10. Javascript函数的基本概念+匿名立即执行函数

    函数声明.函数表达式.匿名函数 函数声明:function fnName () {…};使用function关键字声明一个函数,再指定一个函数名,叫函数声明. 函数表达式 var fnName = f ...