为什么导出的 HBase table 比原来的大 4 倍?
Why exported HBase table is 4 times bigger than its original?
我需要在更新到较新版本之前备份 HBase table。我决定使用标准 Export 工具将 table 导出到 hdfs,然后将其移动到本地文件系统。由于某种原因,导出的 table 比原来的大 4 倍:
hdfs dfs -du -h
1.4T backup-my-table
hdfs dfs -du -h /hbase/data/default/
417G my-table
可能是什么原因?它与压缩有某种关系吗?
P.S。也许我制作备份的方式很重要。首先我做了一个 snapshot from target table, then cloned 到一个副本 table,然后从这个副本 table 中删除了不必要的列族(所以我预计结果大小会小 2 倍),然后我 运行 此副本上的导出工具 table。
为未来的访问者更新: 这是导出 table 压缩
的正确命令
./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
或其他压缩技术进行了压缩。像这样
create 't1', { NAME => 'cf1', COMPRESSION => 'SNAPPY' }
Compression support Check
$ 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 }
我需要在更新到较新版本之前备份 HBase table。我决定使用标准 Export 工具将 table 导出到 hdfs,然后将其移动到本地文件系统。由于某种原因,导出的 table 比原来的大 4 倍:
hdfs dfs -du -h
1.4T backup-my-table
hdfs dfs -du -h /hbase/data/default/
417G my-table
可能是什么原因?它与压缩有某种关系吗?
P.S。也许我制作备份的方式很重要。首先我做了一个 snapshot from target table, then cloned 到一个副本 table,然后从这个副本 table 中删除了不必要的列族(所以我预计结果大小会小 2 倍),然后我 运行 此副本上的导出工具 table。
为未来的访问者更新: 这是导出 table 压缩
的正确命令./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
或其他压缩技术进行了压缩。像这样
create 't1', { NAME => 'cf1', COMPRESSION => 'SNAPPY' }
Compression support Check
$ 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 }