hive on spark 是hive 使用spark作为它的执行引擎。set hive.execution.engine=spark;
hive on spark仅仅在特定版本的spark测试过,所以需要选择合适的hive版本和spark版本。hive3.0.x对应spark2.3.0,hive2.3.x对应spark2.0.0,hive2.2.x、hive2.1.x对应spark1.6.0,hive2.0.x对应spark1.5.0。
spark安装
yarn mode:
http://spark.apache.org/docs/latest/running-on-yarn.html
standalone mode:
https://spark.apache.org/docs/latest/spark-standalone.html
hive on spark 默认支持spark on yarn 模式。
安装并启动spark
1.安装spark
安装/构建兼容版本。可以在github hive项目的pom.xml中spark.version的值找出hive 各个版本测试通过的兼容的spark版本。
安装/构建兼容发行版。每个版本的spark 都有几个发行版,对应不同版本的hadoop。
2.启动spark集群
记下
配置yarn
启用fair scheduler,而不使用capacity scheduler。
修改yarn-site.xml文件,添加
配置hive
1.添加spark 依赖到hive
在hive2.2.0 之前版本,将spark-assembly jar链接到HIVE_HOME/lib。
从hive2.2.0开始,hive on spark 需要spark 2.0.0及以上版本,不再有assembly jar了。故假如以yarn mode运行(yarn-client 或者yarn-cluster),将下面jar链接到HIVE_HOME/lib:scala-library、spark-core、spark-network-common
2.配置hive execution
set hive.execution.engine=spark;
查看https://cwiki.apache.org/confluence/display/Hive/Configuration+Properties#ConfigurationProperties-Spark了解更多配置。
3.给hive配置spark-application configs。查看http://spark.apache.org/docs/latest/configuration.html 。有两种方式,既可以通过在hive classpath下新建一个spark-defaults.conf文件,里面写配置,也可以把配置直接写在hive-site.xml中,主要配置有:
set spark.master=
set spark.eventLog.enabled=true;
set spark.eventLog.dir=
set spark.executor.memory=512m;
set spark.serializer=org.apache.spark.serializer.KryoSerializer;
配置解释:
spark.executor.memory:每一个executor进程使用的内存大小
spark.executor.cores:每一个executor进程的核心数
spark.yarn.executor.memoryOverhead:每一个executor进程分配的heap memory。