Hive集成HBase实践
#step1: create hive table 't_test'
hive -e "
create table test.t_user(id int,name string,age int)
row format delimited
fields terminated by '\t';
"
#step2: prepare dataset and load into hive table 't_test'
cat /tmp/t_user.txt
----------------------
101 Jack 12
102 Michael 18
103 John 21
104 July 20
hive -e "
load data local inpath '/tmp/t_user.txt' overwrite into table test.t_user;
"
#step3: create hbase mapping table 't_user'
echo "create 't_user','i'" | hbase shell
#step4: create external hive table 't_user_hbase' related with hbase table 't_uesr'
hive -e "
create external table test.t_user_hbase(id int, name string, age int)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ('hbase.columns.mapping' = ':key,i:name,i:age')
TBLPROPERTIES('hbase.table.name' = 't_user');
"
#step5: copy data from hive raw table 't_user' to hbase table 't_user'
hive -e "
insert overwrite table test.t_user_hbase select id,name,age from test.t_user;
"