Hbase与hive整合

//hive与hbase整合
create table lectrure.hbase_lecture10(sname string, score int) stored by ‘org.apache.hadoop.hive.hbase.HBaseStorageHandler‘ whth serdeproperties("hbase.columns.mapping" = ‘:key,cf1:score‘)
tblproperties("hbase.table.name" = "hbase_lecture10");

with serdeproperties : 指定属性,这里指定Hbase表和hive的字段映射关系,注意这里的字段个数和顺序必须和前面Hive表的属性保持一致。第一个字段:key映射到Hive中的sname字段,后面字段依此类推。

//加载数据,可以通过Hive支持的insert overwrite方式将一个表的数据导入HBase. (耗时异常长)
insert overwrite table lecture.hbase_lectrure10 Select sname, score From lecture.lectrue10;

//hbase创建表和插入数据
create ‘hbase_test‘,{NAME => ‘cf1‘}

put ‘hbase_test‘,‘a‘,‘cf1:v1‘,‘1‘

//创建hive外部表
create external table lecture.hbase_test(key string, value int)
stored by ‘org.apache.hadoop.hive.hbase.HBaseStorageHandler‘ with serdeproperties("hbase.columns.mapping"=":key,cf1:v1")
tblproperties("hbase.table.name"="hbase_test");

//字段映射属性

Hbase.columns.mapping 字段映射属性。到目前为止,一个Hive表可以包含N个字段,该属性也需要包含N个声明
hbase.table.default.storage.type 可以是任意的string(默认)或二进制类型。该选项只能在Hive 0.9.*有效

//多列和多列族映射

create table hbase_test2(key string, value1 string, value2 string, value3 string)
stored by ‘org.apache.hadoop.hive.hbase.HBaseStorageHandler‘
with serdeproperties
("hbase.columns.mapping "=":key,cf1:coll,cf1:col2,cf2:col3")
TBLPROPERTIES("hbase.table.name" = "hbase_test2")

//插入数据

put ‘hbase_test2‘,‘rk1‘,‘cf1:col1‘,‘100‘
put ‘hbase_test2‘,‘rk1‘,‘cf1:col2‘,‘101‘
put ‘hbase_test2‘,‘rk1‘,‘cf1:col3‘,‘102‘
put ‘hbase_test2‘,‘rk2‘,‘cf2:col1‘,‘100‘
put ‘hbase_test2‘,‘rk2‘,‘cf2:col2‘,‘101‘
put ‘hbase_test2‘,‘rk2‘,‘cf2.col3‘,‘102‘

//扫描表查看数据
scan ‘hbase_test2‘

2、Hive Map
(1)通过Hive建表
create table hbase_test3(row_key string,value map<string,int>)
stored by ‘org.apache.hadoop.hive.hbase.HBaseStorageHandler‘
WITH SERDEPROPERTIES("hbase.columns.mapping" = ":key,cf:");

(2)使用Hive语句insert overwrite
insert overwrite table hbase_test3 select sname,map(sname,score) from lecture.lecture 10;

时间: 2024-08-02 11:33:31

Hbase与hive整合的相关文章

Hadoop、HBase、Hive整合安装文档

前期准备(版本匹配): Hadoop 2.x is faster and includes features, such as short-circuit reads, which will help improve your HBase random read profile. Hadoop 2.x also includes important bug fixes that will improve your overall HBase experience. HBase 0.98 depr

HBase 与Hive数据交互整合过程详解

Hive和Hbase整合理论 1.为什么hive要和hbase整合 2.整合的优缺点 优点: (1).Hive方便地提供了Hive QL的接口来简化MapReduce的使用, 而HBase提供了低延迟的数据库访问.如果两者结合,可以利 用MapReduce的优势针对HBase存储的大量内容进行离线的计算和分析. (2).操作方便,hive提供了大量系统功能 缺点: 性能的损失,hive有这样的功能, 他支持通过类似sql语句的语法来操作hbase 中的数据, 但是速度慢. 3.整合需要做什么样的

Hive整合HBase——通过Hive读/写 HBase中的表

写在前面一: 本文将Hive与HBase整合在一起,使Hive可以读取HBase中的数据,让Hadoop生态系统中最为常用的两大框架互相结合,相得益彰. 写在前面二: 使用软件说明 约定所有软件的存放目录: /home/yujianxin 一.Hive整合HBase原理 Hive与HBase整合的实现是利用两者本身对外的API接口互相进行通信,相互通信主要是依靠hive-hbase-handler-0.9.0.jar工具类,如下图 Hive与HBase通信示意图 二.具体步骤 安装前说明 1.关

创建hive整合hbase的表总结

[Author]: kwu 创建hive整合hbase的表总结,如下两种方式: 1.创建hive表的同步创建hbase的表 CREATE TABLE stage.hbase_news_company_content(key string comment "流水号", news_id string comment "新闻id", news_content string comment "文章内容") STORED BY 'org.apache.ha

大数据学习系列之五 ----- Hive整合HBase图文详解

引言 在上一篇 大数据学习系列之四 ----- Hadoop+Hive环境搭建图文详解(单机) 和之前的大数据学习系列之二 ----- HBase环境搭建(单机) 中成功搭建了Hive和HBase的环境,并进行了相应的测试.本文主要讲的是如何将Hive和HBase进行整合. Hive和HBase的通信意图 Hive与HBase整合的实现是利用两者本身对外的API接口互相通信来完成的,其具体工作交由Hive的lib目录中的hive-hbase-handler-*.jar工具类来实现,通信原理如下图

Hive 整合Hbase

摘要 Hive提供了与HBase的集成,使得能够在HBase表上使用HQL语句进行查询 插入操作以及进行Join和Union等复杂查询.同时也可以将hive表中的数据映射到Hbase中. ? ? 应用场景 2.1 将ETL操作的数据存入HBase ? ? ? ? ?? ? 2.2 HBase作为Hive的数据源 ? ? ? ? 2.3 构建低延时的数据仓库 环境准备 ? ? ? ? 3.1 hive与hbase整合环境配置 修改hive-site.xml文件,添加配置属性(zookeeper的地

Hive over HBase和Hive over HDFS性能比较分析

转载至: http://lxw1234.com/archives/2015/04/101.htm   mark - 参考学习 环境配置: hadoop-2.0.0-cdh4.3.0 (4 nodes, 24G mem/node) hbase-0.94.6-cdh4.3.0 (4 nodes,maxHeapMB=9973/node) hive-0.10.0-cdh4.3.0 查询性能比较: query1: select count(1) from on_hdfs; select count(1)

Hbase和Hive之间的区别知多少?

Hive是为了简化编写MapReduce程序而生的,使用MapReduce做过数据分析的人都知道,很多分析程序除业务逻辑不同外,程序流程基本一样.在这种情况下,就需要Hive这样的用戶编程接口.Hive本身不存储和计算数据,它完全依赖于HDFS和MapReduce,Hive中的表纯逻辑,就是些表的定义等,也就是表的元数据.使用SQL实现Hive是因为SQL大家都熟悉,转换成本低,类似作用的Pig就不是SQL. HBase为查询而生的,它通过组织起节点內所有机器的內存,提供一個超大的內存Hash表

hbase与hive 小结

1. 两者区别是什么? Apache Hive是一个构建在Hadoop基础设施之上的数据仓库.通过Hive可以使用HQL语言查询存放在HDFS上的数据.HQL是一种类SQL语言,这种语言最终被转化为Map/Reduce. 虽然Hive提供了SQL查询功能,但是Hive不能够进行交互查询--因为它只能够在Haoop上批量的执行Hadoop. Apache HBase是一种Key/Value系统,它运行在HDFS之上.和Hive不一样,Hbase的能够在它的数据库上实时运行,而不是运行MapRedu