码迷,mamicode.com
首页 > 其他好文 > 详细

spark1.0属性配置以及spark-submit简单使用

时间:2014-06-25 20:12:25      阅读:286      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   code   http   ext   

在spark1.0中属性支持三种配置方式:

1、代码

在代码中构造SparkConf时指定master、appname或者key-value等

val conf = new SparkConf();
conf.setAppName("WordCount").setMaster(" spark://hadoop000:7077")
val sc = new SparkContext(conf)
val conf = new SparkConf();
conf.set("spark.executor.memory", "1g")
val sc = new SparkContext(conf)

2、命令行

在使用spark-submit或者spark-shell提交应用程序时,用命令行参数提交;

具体参数通过查看spark-submit --help 或者spark-shell --help得知;

spark-submit使用参见官方文档:http://spark.apache.org/docs/latest/submitting-applications.html

spark-submit --name SparkSubmit_Demo --class com.luogankun.spark.WordCount --master spark://hadoop000:7077 \
--executor-memory 1G --total-executor-cores 1 /home/spark/data/spark.jar hdfs://hadoop000:8020/hello.txt

注意:

1)此处虽然设置了name,但是如果在代码层面已经设置了setAppName("xxx"),那么此处的name是不生效的,因为代码层面设置参数的优先级大于命令行层面;

2)executor-memory是每个worker占用的,而executor-cores是所有worker一共占用;

3、配置文件

在spark1.0中使用conf/spark-defaults.conf配置文件设定,形如:

spark.master spark://hadoop000:7077
spark.local.dir /home/spark/spark_shuffle/    #配置spark shuffle数据存放路径
spark.executor.memory 1g

默认情况下spark-submit是会读取该配置文件,也可以通过参数设置读取其他配置文件,参见:spark-submit --properties-file

参数配置参见:http://spark.apache.org/docs/latest/configuration.html

 

注意三种属性设置的优先级:代码>命令行>配置文件

spark1.0属性配置以及spark-submit简单使用,布布扣,bubuko.com

spark1.0属性配置以及spark-submit简单使用

标签:style   class   blog   code   http   ext   

原文地址:http://www.cnblogs.com/luogankun/p/3805566.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!