Hadoop 从零开始学习系列-hive与hbase外部关联表建立及数据导入

由于项目中要把统计的结果提供给外部使用,由于hive查询启动mapreduce等等太慢,所以考虑把数据导入到hbase,用hbase实现。

其中调研过用bulkload来把数据导入hbase。这个下篇再记。此篇只记hive建立外部表及数据导入

建立外部表的sql

create table test_outside (key string,sip string,cip string) stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' with serdeproperties  ("hbase.columns.mapping" = ":key,fr:sip,fr:cip") tblproperties("hbase.table.name" = "test_hbase");
如果table前有external字段,则需要HBASE表存在。

导入数据,注意,导入的数据里,key对应的字段必须不为null且长度大于0,不然会抛错

 insert overwrite table test_outside select key,sip,cip from test where dt='20130724' ;

输入hbase shell

scan 'test_hbase'可以看到所有导入的记录

猜你喜欢

转载自blog.csdn.net/jdzms23/article/details/45077953