数据从HDFS-->HIVE-->HBASE 执行过程

1、数据已经load进去hdfs

2、hive、hbase已经安装成功(我用的是hadoop 2.4 hbase 0.98.12  hive 1.2.13、开始!

4、在hive建立表同时生成对应的一张Hbase表,分别在hive和hbase用show tables;和list查看是否生成对应的表

create table hive3 (key string,phone string,price int,room string,large string,floor string,n string,site string,compay string)

STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'

WITH SERDEPROPERTIES

("hbase.columns.mapping" = ":key,info:phone,info:price,info:room,info:large,info:floor,info:n,info:site,info:compay") TBLPROPERTIES ("hbase.table.name"="hive_hbase3");

5、建立一张hive表,用来存放hdfs打入的数据,我这里是以‘|’分割的数据

​create table hive2(id string,home string,name string,phone string,price int,room string,large string,floor string,n string,site string,compay string) row format delimited fields terminated by '|' lines terminated by '
' stored as textfile;​

6、把已经存在于hdfs的数据load进去hive,

命令:load data local inpath '' into table xxx;​

7、select * from xxx(5 建立的表);

8、insert into hive3 (key,phone,price ...) 

     select CONCAT(unix_timestamp(),"-",id,"-",name) ​ as key ,phone,price ... from hive2;

(注:我这里是时间戳+id+name 组合成的key)

9、分别count一下数据,看数据是不是正确的   hbase里面可以scan一下或者count一下



原创:转载注明出处!​
原文地址:https://www.cnblogs.com/tnsay/p/5753547.html