【问题标题】:How to process all Hbase data with Hive如何使用 Hive 处理所有 Hbase 数据
【发布时间】:2019-07-13 09:12:29
【问题描述】:

我有一个包含 750GB 数据的 HBase。 HBase 中的所有数据都是时间序列传感器数据。而且,我的行键设计是这样的;

设备ID、传感器ID、时间戳

我想为批处理准备 hbase 中的所有数据(例如,HDFS 上的 CSV 格式)。但是hbase里面有很多数据。我可以使用 hive 准备数据而不获取部分数据吗?因为,如果我将使用传感器 id 获取数据(扫描查询与起始行),我必须为每次指定起始行和结束行。我不想这样做。

【问题讨论】:

    标签: hive mapreduce hdfs hbase batch-processing


    【解决方案1】:

    您可以尝试使用Hive-Hbase integration,然后将map hbase table 数据转至hive table

    然后通过使用 Hive-Hbase 表,我们可以将 Hbase 表的完整转储创建到常规 Hive 表(orc、parquet..etc)。

    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>;
    

    有关导出 hive 表的更多详细信息/选项,请参阅 this 链接。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多