操作hbase,hive建连接,impala操作hbase查询
1.进入hbase命令:hbase shell
2.建表
create ‘test’,‘c f’: 建表时必须指定表名和列族名
list :列举表信息,(相当于hive的show tables)
describe :描述表信息
3.hive建hbase的外部表
create externaltable hbasetest4(rowkey string,cf_amap<string,string>)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITHSERDEPROPERTIES ("hbase.columns.mapping" ="cf:")
TBLPROPERTIES ("hbase.table.name" = "test")
create externaltable hbasetest3(rowkey string,a string, b string)STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITHSERDEPROPERTIES ("hbase.columns.mapping" =":key,cf:a,cf:b")
TBLPROPERTIES ("hbase.table.name" = "test");
建表时,两个标红处要对应。弄清楚要建的映射表的字段是集合还是单一字段!
4.hive建hbase内部表
create table hbase2(rowkeystring,a string, b string) STORED BY'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITHSERDEPROPERTIES ("hbase.columns.mapping" =":key,cf:a,cf:b")
TBLPROPERTIES ("hbase.table.name" = "hbase3");
hive表名可以和hbase表名不相同。