赞
踩
HBase是一种非关系型分布式数据库,无法进行多表关联等关系型数据库能执行的操作,但是基于HBase高容量,高吞吐的特征,我们可以将HBase的表映射到Hive中进行存储,下面展示存储案例.
create_namespace 'testConnectHive'
create 'testConnectHive:student','stuinfo','schoolinfo'
- hbase(main):004:0> put 'testConnectHive:student','1001','stuinfo:stuname','zhangsan'
- Took 0.6039 seconds
- hbase(main):005:0> put 'testConnectHive:student','1001','stuinfo:stuno','1001'
- Took 0.0107 seconds
- hbase(main):006:0> put 'testConnectHive:student','1001','stuinfo:stugender','male'
- Took 0.1695 seconds
- hbase(main):007:0> put 'testConnectHive:student','1001','schoolinfo:schoolname','beijingdaxue'
- Took 0.0342 seconds
- hbase(main):008:0> put 'testConnectHive:student','1001','schoolinfo:schoollocation','beijing'
desc 'testConnectHive:student'
nohup hive --service hiveserver2 &
- create database testConnectHive;
- use testConnectHive;
- create external table student(
- id string,
- stuname string,
- stuno string,
- schoolname string,
- schoollocation string
- )stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' with
- serdeproperties ('hbase.columns.mapping'=':key,stuinfo:stuname,stuinfo:stuno,schoolinfo:schoolname,schoolinfo:schoollocation')
- tblproperties ('hbase.table.name'='testConnectHive:student');
- select * from student;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。