正文
spark读取hbase的hive,sparksql读取hive
小程序:扫一扫查出行
【扫一扫了解最新限行尾号】
复制小程序
【扫一扫了解最新限行尾号】
复制小程序
【数仓】对比spark-hive的两种分布式计算模式
Spark on Hive是以Spark角度看Hive是数据源,在Spark中配置Hive,并获取Hive中的元数据,然后用SparkSQL操作hive表的数据并直接翻译成SparkRDD任务。Hive只是作为一个Spark的数据源。
local[ ]:启动跟cpu数目相同的 executor 上述情况中,local[N]与local[*]相当于用单机的多个线程来模拟spark分布式计算,通常用来检验开发出来的程序逻辑上有没有问题。其中N代表可以使用N个线程,每个线程拥有一个core。
HIVE,一个数据仓库系统。它将数据结构映射到存储的数据中,通过 SQL 对大规模的分布式存储数据进行读、写、管理。 根据定义的数据模式,以及输出 Storage,它会对输入的 SQL 经过编译、优化,生成对应引擎的任务,然后调度执行生成的任务。
首先我们说一说大数据分析,现在的大数据分析体系以Hadoop生态为主,而近年来逐渐火热的Spark技术也是主要的生态之一。可以这么说,Hadoop技术只能算是以HDFS+YARN作为基础的分布式文件系统,而不是数据库。
源码级解读如何解决Spark-sql读取hive分区表执行效率低问题
1、对此现象的优化可以是,将文件存为符合hive table文件的格式,然后使用hive load将产生的结果文件直接move到指定目录下。
2、为了让Spark能够连接到Hive的原有数据仓库,我们需要将Hive中的hive-site.xml文件拷贝到Spark的conf目录下,这样就可以通过这个配置文件找到Hive的元数据以及数据存放。
3、Map Join Spark SQL默认对join是支持使用broadcast机制将小表广播到各个节点上,以进行join的。但是问题是,这会给Driver和Worker带来很大的内存开销。因为广播的数据要一直保留在Driver内存中。
4、Hive在极大数据或者数据不平衡等情况下,表现往往一般,因此也出现了presto、spark-sql等替代品。
5、影响Hive效率的主要因素有数据倾斜、数据冗余、job的IO以及不同底层引擎配置情况和Hive本身参数和HiveSQL的执行等。本文主要从建表配置参数方面对Hive优化进行讲解。
hadoop和spark的区别
1、如果说比较的话就 Hadoop Map Reduce 和 Spark 比较,因为他们都是大数据分析的计算框架。Spark 有很多行组件,功能更强大,速度更快。
2、不同点前者基于磁盘+内存,磁盘占得比重比较大,而后者侧重于内存+磁盘,内存占得比重比较大,这也是为什么Hadoop没spark速度快的根本原因,spark基于内存来做MR,而Hadoop侧重于落地到磁盘来做MR。
3、Hadoop和Spark都是集群并行计算框架,都可以做分布式计算,它们都基于MapReduce并行模型。Hadoop基于磁盘计算,只有map和reduce两种算子,它在计算过程中会有大量中间结果文件落地磁盘,这会显著降低运行效率。
4、是个大的框架,spark是这个大的架构下的一个内存计算框架,负责计算,同样作为计算框架的还有mapreduce,适用范围不同,比如hbase负责列式存储,hdfs文件系统等等。另外spark是可以脱离hadoop架构单独作为计算引擎使用的。
关于spark读取hbase的hive和sparksql读取hive的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。