不多说,直接上干货!

 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)  

最新文章

  1. 1、Python基本概念
  2. WinPipe后门程序代码示例(仅限技术交流)
  3. JavaScript UI选型及Jquery EasyUI使用经验谈
  4. BZOJ2706 : [SDOI2012]棋盘覆盖
  5. gulp-uglify《JS压缩》----gulp系列(四)
  6. Mustache.js前端模板引擎源码解读
  7. Android 接收短信
  8. CAS单点登录配置[3]:服务器端配置
  9. 测试stopwatch频率
  10. Andrdoid中相应用程序的行为拦截实现方式之----从Java层进行拦截
  11. nginx 全局配置
  12. OL6.3 设置本地yum源
  13. python3入门教程
  14. h5手势密码开发(使用jq)
  15. adnanh webhook 框架 hook rule
  16. JavaScript debugger 语句
  17. Java网络编程学习A轮_03_抓包分析TCP四次挥手
  18. 9.python爬虫--pyspider
  19. Mybatis中接口和对应的mapper文件位置配置深入剖析
  20. mysql mariadb 乱码

热门文章

  1. Python(八) 正则表达式与JSON
  2. angularjs 页面缓存及动态刷新解决方案
  3. 概率编程:《贝叶斯方法概率编程与贝叶斯推断》中文PDF+英文PDF+代码
  4. 使用 docker 安装多版本的 MySQL
  5. CentOS 7上安装gitlab-runner
  6. Cocos2d-x学习笔记(20)(TestCpp源代码分析-4)
  7. modSecurity规则学习(三)——SecRule
  8. es6 -- Iterator 和 for...of 循环
  9. 洛谷P1722 矩阵 II
  10. Kinect 开发 —— 开发前的准备工作