1. Hive中的表是纯逻辑表,就只是表的定义等,即表的元数据。Hive本身不存储数据,它完全依赖HDFS和MapReduce。这样就可以将结构化的数据文件映射为为一张数据库表,并提供完整的SQL查询功能,并将SQL语句最终转换为MapReduce任务进行运行。 而HBase表是物理表,适合存放非结构化的数据。
2. Hive是基于MapReduce来处理数据,而MapReduce处理数据是基于行的模式;HBase处理数据是基于列的而不是基于行的模式,适合海量数据的随机访问。
3. HBase的表是疏松的存储的,因此用户可以给行定义各种不同的列;而Hive表是稠密型,即定义多少列,每一行有存储固定列数的数据。
4. Hive使用Hadoop来分析处理数据,而Hadoop系统是批处理系统,因此不能保证处理的低迟延问题;而HBase是近实时系统,支持实时查询。
5. Hive不提供row-level的更新,它适用于大量append-only数据集(如日志)的批任务处理。而基于HBase的查询,支持和row-level的更新。
6. Hive提供完整的SQL实现,通常被用来做一些基于历史数据的挖掘、分析。而HBase不适用与有join,多级索引,表关系复杂的应用场景。
HBase是个基于HDFS的数据库。Hive是用SQL替代写MR的编程框架,做Hadoop上会把用户提交的SQL语句做语法分析,执行计划等一堆乱七八糟的事后变成MR job提交去跑,返回结果给用户。不然每次都写MR很麻烦的,有这个写个SQL就可以拿到等效的结果,很适合运营童鞋用。当然Hive也有HBase的Connector,用这个Connnector后可以写SQL查询HBase的数据而不是HDFS,不过一般不这么搞。
Reasons to use Hive on HBase:
A lot of data sitting in HBase due to its usage in a real-time environment, but never used for analysis
Give access to data in HBase usually only queried through MapReduce to people that don’t code (business analysts)
When needing a more flexible storage solution, so that rows can be updated live by either a Hive job or an application and can be seen immediately to the other
Reasons not to do it:
Run SQL queries on HBase to answer live user requests (it’s still a MR job)
Hoping to see interoperability with other SQL analytics systems
Hive can use tables that already exist in HBase or manage its own ones, but they still all reside in the same HBase instance
When using an already existing table, defined as EXTERNAL, you can create multiple Hive tables that point to it
参考:www.cs.kent.edu/~jin/Cloud12Spring/HbaseHivePig.pptx