将HBase配置文件hbase-site.xml拷贝到$IMPALA_HOME/conf目录下,或者手工创建一个hbase-site.xml文件,只需添加hbase.zookeeper.quorum属性值即可。
在HBase中创建与Hive关联的表,可以通过HBase Shell或者程序创建,此文通过shell创建,命令如下:
>create ‘table_name’,’d’
在Hive中创建与HBase中表相关联的外部表,命令如下:
CREATE TABLE hbase_ table_name (key type, col1 type,col2 type)
STORED BY
'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES (
"hbase.columns.mapping" = ":key,d: col1,d: col2" )
TBLPROPERTIES("hbase.table.name" = " table_name ");
注意:
1.因为在Hive创建的外部表需要在Impala中使用,因此只能定义为boolean, tinyint, smallint, int, bigint, float, double, timestamp, string;
2.如果数据是从HBase中插入的,key的定义类型只能为string,否则该字段会为空;如果数据是从Hive中Load导入的,key的定义类型只要与Hive导入文件的该字段定义一致即可,但建议定义为string。
从Impala-Shell查看Impala与HBase整合结果,记得查询之前先要刷新元数据。
在HBase中创建与Hive关联的表,可以通过HBase Shell或者程序创建,此文通过shell创建,命令如下:
>create ‘table_name’,’d’
在Hive中创建与HBase中表相关联的外部表,命令如下:
CREATE TABLE hbase_ table_name (key type, col1 type,col2 type)
STORED BY
'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES (
"hbase.columns.mapping" = ":key,d: col1,d: col2" )
TBLPROPERTIES("hbase.table.name" = " table_name ");
注意:
1.因为在Hive创建的外部表需要在Impala中使用,因此只能定义为boolean, tinyint, smallint, int, bigint, float, double, timestamp, string;
2.如果数据是从HBase中插入的,key的定义类型只能为string,否则该字段会为空;如果数据是从Hive中Load导入的,key的定义类型只要与Hive导入文件的该字段定义一致即可,但建议定义为string。
从Impala-Shell查看Impala与HBase整合结果,记得查询之前先要刷新元数据。