淘先锋技术网

首页 1 2 3 4 5 6 7

1、前提分析

  • hive是用来分析数据的、
  • hbase是用来存储数据的

2、整合hive和hbase

2.1、将hbase里的表数据关联到hive中

create database hive2hbase;
create external table if not exists hbase2hive(
rowkey string,
family1 map<string,string>,
family2 map<string,string>,
info map<string,string>
)

stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
with serdeproperties("hbase.columns.mapping" = ":key,family1:,family2:,info:")
tblproperties("hbase.table.name" = "mine:student");

select * from hbase2hive;

 

数据会随着hbase的数据的增加而增加;

select * from hbase2hive;

2.1、将hive里的表数据关联到hbase中

create table hive2hbase(
id string,
name string,
sex string,
age int,
address string
)

stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
with serdeproperties("hbase.columns.mapping" = ":key,family1:name,family1:sex,family1:age,family1:address")
tblproperties("hbase.table.name" = "mine:hive2hbase");

加载数据到hive表:

insert into hive2hbase select * from student;