spark第四篇:Running Spark on YARN
确保HADOOP_CONF_DIR或者YARN_CONF_DIR指向hadoop集群配置文件目录。这些配置用来写数据到hdfs以及连接yarn ResourceManager。(在$SPARK_HOME/conf/spark-env.sh中,添加export HADOOP_CONF_DIR=/home/koushengrui/app/hadoop/etc/hadoop)。The configuration contained in this directory will be distributed to the YARN cluster so that all containers used by the application use the same configuration. If the configuration references Java system properties or environment variables not managed by YARN, they should also be set in the Spark application’s configuration (driver, executors, and the AM when running in client mode).
spark on yarn 有两种部署模式。In cluster mode, the Spark driver runs inside an application master process which is managed by YARN on the cluster, and the client can go away after initiating the application. In client mode, the driver runs in the client process, and the application master is only used for requesting resources from YARN。cluster 模式,spark 驱动程序运行在应用主进程内。client 模式,驱动程序运行在客户端进程中,应用主进程只负责向yarn 请求资源。
不像spark standalone 和 mesos 模式,这两种模式下master 的地址由--master 参数指定,yarn 模式,ResourceManager 的地址从hadoop 配置中取。因此,--master 参数的值是yarn。
以cluster 模式启动应用:
./spark-submit --class class_name --master yarn --deploy-mode cluster [options] <app jar> [app options]
例如:
./spark-submit --class org.apache.spark.examples.SparkPi \
--master yarn \
--deploy-mode cluster \
--driver-memory 4g \
--executor-memory 2g \
--executor-cores 1 \
--queue queue_name \
/path/spark-example*.jar \
10
The above starts a YARN client program which starts the default Application Master. Then SparkPi will run as a child thread of Application Master. The client will periodically poll the Application Master for status updates and display them in the console. The client will exit once your application has finished running。
以client 模式启动应用:
和上面一样,除了--deploy-mode 参数值为client
./spark-submit --class class_name --master yarn --deploy-mode client [options] <app jar> [app options]
例如可以以client 模式运行spark-shell:
./spark-shell --master yarn --deploy-mode client
添加其他jar
利用spark把hive数据导到hbase:
spark-submit \
--class com.kou.spark.util.Hive2Hbase \
--master yarn \
--deploy-mode client \
--executor-memory 500m \
--driver-memory 500m \
--num-executors 2 \
--executor-cores 2 \
--queue ${spark_queuename} \
--conf spark.sql.autoBroadcastJoinThreshold=20971520 \
--conf spark.default.parallelism=40 \
--conf spark.sql.shuffle.partitions=40 \
--conf spark.speculation=false \
--conf spark.task.maxFailures=40 \
--conf spark.akka.timeout=300 \
--conf spark.network.timeout=300 \
--conf spark.yarn.max.executor.failures=40 \
--conf spark.executor.extraJavaOptions="-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+ParallelRefProcEnabled -XX:+CMSClassUnloadingEnabled -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -XX:+HeapDumpOnOutOfMemoryError -verbose:gc " \
spark-hive2Hbase.jar "${appName}" "${sql}" "${outputTable}" "${phoenix_jdbc_url}"
hiveContext.sql("use sx_ela_safe")
hiveContext.sql("set mapred.job.queue.name=" + HDP_QUEUE_NAME)
hiveContext.sql("set hive.input.format=org.apache.hadoop.hive.ql.io.CombineHiveInputFormat")
hiveContext.sql("set hive.merge.mapredfiles=true")
hiveContext.sql("set hive.merge.smallfiles.avgsize=100000000")
hiveContext.sql("set mapred.combine.input.format.local.only=false")
// 创建上下文
val sparkConf = new SparkConf().setAppName(s"${args(4)}")
.set("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
.set("spark.kryoserializer.buffer.max", "300m")
.set("spark.sql.parquet.compression.codec", "snappy")
.set("spark.sql.parquet.mergeSchema", "true")
.set("spark.sql.parquet.binaryAsString", "true")
.set("spark.streaming.kafka.maxRatePerPartition", s"${args(2)}")
def InitEnvConfig(conf: SparkConf) = {
brokers = conf.get(KAFKA_METADATA_BROKER_LIST)
zkConnectString = conf.get(ZOOKEEPER_QUORUM)
phoenixZkUrl = conf.get(PHOENIX_JDBC_URL)
hdfsRootPath = conf.get(HDFS_ROOT_PATH)
spark_deploy_mode = conf.get(SPARK_MASTER_URL)
HDP_QUEUE_NAME = conf.get(HADOOP_QUEUE_NAME)
}
spark第四篇:Running Spark on YARN的更多相关文章
- spark第六篇:Spark Streaming Programming Guide
预览 Spark Streaming是Spark核心API的扩展,支持高扩展,高吞吐量,实时数据流的容错流处理.数据可以从Kafka,Flume或TCP socket等许多来源获取,并且可以使用复杂的 ...
- spark第十篇:Spark与Kafka整合
spark与kafka整合需要引入spark-streaming-kafka.jar,该jar根据kafka版本有2个分支,分别是spark-streaming-kafka-0-8和spark-str ...
- 第四篇:Spark SQL Catalyst源码分析之TreeNode Library
/** Spark SQL源码分析系列文章*/ 前几篇文章介绍了Spark SQL的Catalyst的核心运行流程.SqlParser,和Analyzer,本来打算直接写Optimizer的,但是发现 ...
- spark第七篇:Spark SQL, DataFrame and Dataset Guide
预览 Spark SQL是用来处理结构化数据的Spark模块.有几种与Spark SQL进行交互的方式,包括SQL和Dataset API. 本指南中的所有例子都可以在spark-shell,pysp ...
- Running Spark on YARN
Running Spark on YARN 对 YARN (Hadoop NextGen) 的支持是从Spark-0.6.0开始的,后续的版本也一直持续在改进. Launching Spark on ...
- Spark(四十九):Spark On YARN启动流程源码分析(一)
引导: 该篇章主要讲解执行spark-submit.sh提交到将任务提交给Yarn阶段代码分析. spark-submit的入口函数 一般提交一个spark作业的方式采用spark-submit来提交 ...
- spark调优篇-Spark ON Yarn 内存管理(汇总)
本文旨在解析 spark on Yarn 的内存管理,使得 spark 调优思路更加清晰 内存相关参数 spark 是基于内存的计算,spark 调优大部分是针对内存的,了解 spark 内存参数有也 ...
- spark调优篇-spark on yarn web UI
spark on yarn 的执行过程在 yarn RM 上无法直接查看,即 http://192.168.10.10:8088,这对于调试程序很不方便,所以需要手动配置 配置方法 1. 配置 spa ...
- Spark(四十四):使用Java调用spark-submit.sh(支持 --deploy-mode client和cluster两种方式)并获取applicationId
之前也介绍过使用yarn api来submit spark任务,通过提交接口返回applicationId的用法,具体参考<Spark2.3(四十):如何使用java通过yarn api调度sp ...
随机推荐
- Laravel Gate 授权方式的使用指南
参考链接:An Introduction to Laravel Authorization Gates 本文使用 Laravel 的 Gate 授权方式 实现一个基于用户角色的博客发布系统. 在系统包 ...
- layer弹出框插件参数及方法介绍
layerui下载:http://www.layui.com 更多参数请阅读开发文档:http://www.layui.com/doc/modules/layer.html Layui 是一款采用自身 ...
- 备忘录(Memento)模式
*备忘录模式(Memento):在不破坏封装性的前提下,捕获一个对戏的内部状态, * 并在该对象之外保存这个状态.这样以后就能恢复到原来保存的状态 *Originator(发起人): 负责创建一个备忘 ...
- C# -- 泛型(1)
简介: 先看看泛型的概念--“通过参数化类型来实现在同一份代码上操作多种数据类型.利用“参数化类型”将类型抽象化,从而实现灵活的复用”. 很多初学者在刚开始接触泛型的时候会比较难理解 “泛型” 在这里 ...
- 15分XX秒后订单自动关闭(倒计时)
//订单记录 function get_order(){ //请求订单ajax方法 XX.send_api("method",{data},function(){ var date ...
- 关于Lucene分页标准
public IEnumerable<SearchResult> Search(string keyword, string[] fieldNames, int pageSize, int ...
- Can't install Solaris 10 on XenServer 6.5 VM
I have XenServer 6.5 installed on a server, and i have been trying to install Solaris 10 on a VM, it ...
- 初学python - 常见函数使用
*** 读入两个整数 a,b=eval(input()) ***range()函数 创建列表 :range( 1, 11,2) - 产生 [1,11) 相差为2数,2为步长 ***print()函数 ...
- JSON Path表达式
JSON Path 描述 $ 表示根元素 @ 表示当前节点 . 表示子节点 .. 选择所有符合条件的节点 * 所有节点 [] 迭代器标识,如数组下标 [,] 支持迭代器中多选 [start:en ...
- requests利用selenium,代理Ip,云打码,验证码抠图操作 爬取搜狗微信公众号内容
爬取思路,爬取搜狗微信公众号内容,爬取第一层url时请求太快出现验证码,我这里用的蘑菇云代理,并在程序中我判断什么情况下是否+代理,做到合理运用代理ip.爬取第二层url时验证码出现次数更严重(和第一 ...