首先创建外部表:
create external table hbase_mobile_info(key string,city string,dealtime string,imsi string,manufacturer string,meid string,model string,province string, regtime string,version string)
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
with serdeproperties ("hbase.columns.mapping" = ":key,fr:CITY,fr:DEALTIME,fr:IMSI,fr:MANUFACTURER,fr:MEID,fr:MODEL,fr:PROVINCE,fr:REGTIME,fr:VERSION")
tblproperties("hbase.table.name" = "mobile_info");
然后编辑hive-site.xml,添加如下配置:
<property>
<name>hive.aux.jars.path</name>
<value>file:///home/hadoop/cdh4.2.2/hive/lib/hive-hbase-handler-0.10.0-cdh4.2.2.jar,file:///home/hadoop/cdh4.2.2/hive/lib/hbase-0.94.2-cdh4.2.2.jar,file:///home/hadoop/cdh4.2.2/hive/lib/zookeeper-3.4.5-cdh4.2.2.jar</value>
</property>
否则查询hbase表的时候会出现报错:
java.io.IOException: Cannot create an instance of InputSplit class = org.apache.hadoop.hive.hbase.HBaseSplit:org.apache.hadoop.hive.hbase.HBaseSplit