星空网 > 软件开发 > 数据库

Hive HBase Integration 集成

官方文档:https://cwiki.apache.org/confluence/display/Hive/HBaseIntegration

 

1、在hive/lib目录下找到hive-hbase-handler-1.2.1.jar,并把该文件拷贝到hbase/lib目录下。

2、把hbase/lib目录下的所有*.jar文件拷贝到hive/lib目录下。

3、在hive的配置文件中 hive-site.

1 <property>2     <name>hbase.zookeeper.quorum</name>3     <value>node1,node2,node3</value>4 </property>

4、在hive中创建临时表:

1 CREATE TABLE t_test1 2 (id int,name string, age string) 3 STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 4 WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,info:name,info:age") 5 TBLPROPERTIES ("hbase.table.name" = "t_test1","hbase.mapred.output.outputtable" = "t_test1");

HBase表信息:

hbase(main):011:0> describe "t_test1"

测试在hive中插入数据:

hive> insert into t_test1(id,name,age)values(001, 'zs', 'male');

在hbase中同样能查到:

hbase(main):013:0> scan 't_test1'
ROW COLUMN+CELL
1 column=info:age, timestamp=1467337507821, value=male
1 column=info:name, timestamp=1467337507821, value=zs
1 row(s) in 0.3310 seconds

在hbase中插入数据:

hbase(main):015:0> put 't_test1','002','info:age','30'
0 row(s) in 0.0430 seconds

在hive中同样能查到:

hive> select *From t_test1;
OK
2 NULL 30
1 zs male
Time taken: 0.312 seconds, Fetched: 2 row(s)

关联已经存在的hbase表,需要使用external外部表;

应用场景主要针对已经清洗过的数据,放到hbase中,然后通过hql语句根据业务要求将需要的数据提取出来,然后通过sqoop抽取到类似于mysql数据库中,供展现使用。

 




原标题:Hive HBase Integration 集成

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流