如何用Hive处理所有Hbase数据
How to process all Hbase data with Hive
我有一个有 750GB 数据的 HBase。 HBase中的所有数据都是时序传感器数据。而且,我的行键设计是这样的;
设备ID、传感器ID、时间戳
我想准备hbase中的所有数据用于批处理(例如,HDFS上的CSV格式)。但是hbase里面有很多数据。我可以在不部分获取数据的情况下使用配置单元准备数据吗?因为,如果我要使用传感器 ID(使用起始行扫描查询)获取数据,我必须每次都指定起始行和结束行。我不想这样做。
您可以尝试使用 Hive-Hbase integration 然后 map hbase table
数据到 hive table
。
然后通过使用 Hive-Hbase table 我们可以创建 Hbase table 到 Regular Hive table(orc ,镶木地板..等).
Step-1:Create HBase-Hive Integrated table:
hive> CREATE EXTERNAL TABLE <db_name>.<hive_hbase_table_name> (key int, value string)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:val")
TBLPROPERTIES ("hbase.table.name" = "<hbase_table_name>");
Step-2:Create Hive Dump of Hbase table:
hive> create table <db_name>.<table_name> stored as orc as
select * from <db_name>.<hive_hbase_table_name>;
Step-3: Exporting to CSV format:
hive> INSERT OVERWRITE DIRECTORY <hdfs_directory>
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
select * from <db_name>.<hive_hbase_table_name>;
参考 this link 了解更多 details/options 关于导出配置单元 table.
我有一个有 750GB 数据的 HBase。 HBase中的所有数据都是时序传感器数据。而且,我的行键设计是这样的;
设备ID、传感器ID、时间戳
我想准备hbase中的所有数据用于批处理(例如,HDFS上的CSV格式)。但是hbase里面有很多数据。我可以在不部分获取数据的情况下使用配置单元准备数据吗?因为,如果我要使用传感器 ID(使用起始行扫描查询)获取数据,我必须每次都指定起始行和结束行。我不想这样做。
您可以尝试使用 Hive-Hbase integration 然后 map hbase table
数据到 hive table
。
然后通过使用 Hive-Hbase table 我们可以创建 Hbase table 到 Regular Hive table(orc ,镶木地板..等).
Step-1:Create HBase-Hive Integrated table:
hive> CREATE EXTERNAL TABLE <db_name>.<hive_hbase_table_name> (key int, value string)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:val")
TBLPROPERTIES ("hbase.table.name" = "<hbase_table_name>");
Step-2:Create Hive Dump of Hbase table:
hive> create table <db_name>.<table_name> stored as orc as
select * from <db_name>.<hive_hbase_table_name>;
Step-3: Exporting to CSV format:
hive> INSERT OVERWRITE DIRECTORY <hdfs_directory>
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
select * from <db_name>.<hive_hbase_table_name>;
参考 this link 了解更多 details/options 关于导出配置单元 table.