【问题标题】:Why exported HBase table is 4 times bigger than its original?为什么导出的 HBase 表比原来的大 4 倍?
【发布时间】:2017-04-08 23:08:43
【问题描述】:

我需要在更新到新版本之前备份 HBase 表。我决定使用标准的Export 工具将表导出到 hdfs,然后将其移动到本地文件系统。由于某种原因,导出的表格比原始表格大 4 倍:

hdfs dfs -du -h
1.4T    backup-my-table

hdfs dfs -du -h /hbase/data/default/
417G    my-table

可能是什么原因?它是否与压缩有关?

附:也许我做备份的方式很重要。首先我从目标表中创建了一个snapshot,然后将cloned 复制到了一个复制表中,然后从这个复制的表中删除了不必要的列族(所以我预计结果大小会小 2 倍),然后我运行导出工具这个副本表。


为未来的访问者更新:这是使用压缩导出表的正确命令

./hbase org.apache.hadoop.hbase.mapreduce.Export \
 -Dmapreduce.output.fileoutputformat.compress=true \
 -Dmapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.GzipCodec \
 -Dmapreduce.output.fileoutputformat.compress.type=BLOCK \
 -Dhbase.client.scanner.caching=200 \
  table-to-export export-dir

【问题讨论】:

  • 请查看下方希望对您有所帮助!
  • 因为我使用snappy 创建表格。默认情况下可能会应用一些压缩或显式检查您的表创建脚本。

标签: hadoop hbase hdfs


【解决方案1】:

您可能使用SNAPPY 或其他一些压缩技术进行压缩。像这样

create 't1', { NAME => 'cf1', COMPRESSION => 'SNAPPY' }

Compression support Check

Use CompressionTest to verify snappy support is enabled and the libs can be loaded ON ALL NODES of your cluster:

$ hbase org.apache.hadoop.hbase.util.CompressionTest hdfs://host/path/to/hbase snappy

导出命令源以应用压缩:

如果你深入了解导出命令(source),那么你会发现

请参阅以下可以大幅减小尺寸的属性..

mapreduce.output.fileoutputformat.compress=true

mapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.GzipCodec

mapreduce.output.fileoutputformat.compress.type=BLOCK

/*
   * @param errorMsg Error message.  Can be null.
   */
  private static void usage(final String errorMsg) {
    if (errorMsg != null && errorMsg.length() > 0) {
      System.err.println("ERROR: " + errorMsg);
    }
    System.err.println("Usage: Export [-D <property=value>]* <tablename> <outputdir> [<versions> " +
      "[<starttime> [<endtime>]] [^[regex pattern] or [Prefix] to filter]]\n");
    System.err.println("  Note: -D properties will be applied to the conf used. ");
    System.err.println("  For example: ");
    System.err.println("   -D mapreduce.output.fileoutputformat.compress=true");
    System.err.println("   -D mapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.GzipCodec");
    System.err.println("   -D mapreduce.output.fileoutputformat.compress.type=BLOCK");
    System.err.println("  Additionally, the following SCAN properties can be specified");
    System.err.println("  to control/limit what is exported..");
    System.err.println("   -D " + TableInputFormat.SCAN_COLUMN_FAMILY + "=<familyName>");
    System.err.println("   -D " + RAW_SCAN + "=true");
    System.err.println("   -D " + TableInputFormat.SCAN_ROW_START + "=<ROWSTART>");
    System.err.println("   -D " + TableInputFormat.SCAN_ROW_STOP + "=<ROWSTOP>");
    System.err.println("   -D " + JOB_NAME_CONF_KEY
        + "=jobName - use the specified mapreduce job name for the export");
    System.err.println("For performance consider the following properties:\n"
        + "   -Dhbase.client.scanner.caching=100\n"
        + "   -Dmapreduce.map.speculative=false\n"
        + "   -Dmapreduce.reduce.speculative=false");
    System.err.println("For tables with very wide rows consider setting the batch size as below:\n"
        + "   -D" + EXPORT_BATCHING + "=10");
  }

另请参阅getExportFilter,这可能有助于您缩小导出范围。

  private static Filter getExportFilter(String[] args) { 
138     Filter exportFilter = null; 
139     String filterCriteria = (args.length > 5) ? args[5]: null; 
140     if (filterCriteria == null) return null; 
141     if (filterCriteria.startsWith("^")) { 
142       String regexPattern = filterCriteria.substring(1, filterCriteria.length()); 
143       exportFilter = new RowFilter(CompareOp.EQUAL, new RegexStringComparator(regexPattern)); 
144     } else { 
145       exportFilter = new PrefixFilter(Bytes.toBytesBinary(filterCriteria)); 
146     } 
147     return exportFilter; 
148   } 

【讨论】:

  • 另见我关于导出large table的答案
  • 还没有,hadoop 告诉他不能使用 GzipCodec,因为库不是原生的。寻找解决方法
  • RamPrasad G. AdamSkyWalker 的精彩帖子:分享您的发现,了解它是如何工作的。
猜你喜欢
  • 2012-01-09
  • 1970-01-01
  • 1970-01-01
  • 2010-09-20
  • 2013-06-06
  • 1970-01-01
  • 1970-01-01
  • 2015-02-10
  • 1970-01-01
相关资源
最近更新 更多