2011-12-08 58 views
1

我的目的是将数据从Hbase Tables迁移到Flat(比如csv格式)文件。 我使用 TableMapReduceUtil.initTableMapperJob(tableName,scan, GetCustomerAccountsMapper.class,Text.class,Result.class, job); 用于扫描HBase表和MapMapper for Mapper。 我的challange处于强制Reducer将Row值(以平面格式标准化)转储到本地(或Hdfs)文件系统时。 我的问题是我既没有看到Reducer的日志,也没有看到我在Reducer中提到的路径上的任何文件。将数据从HBase迁移到文件系统。 (写Reducer输出到本地或Hadoop文件系统)

这是我的第二或第三先生的工作和第一个严重的工作。经过两天的努力,我仍然无能为力,无法实现自己的目标。

如果有人能够展示正确的方向,那将会很棒。

这里是我的减速代码 -

public void reduce(Text key, Iterable<Result> rows, Context context) 
      throws IOException, InterruptedException { 
FileSystem fs = LocalFileSystem.getLocal(new Configuration()); 
    Path dir = new Path("/data/HBaseDataMigration/" + tableName+"_Reducer" + "/" +  key.toString()); 

FSDataOutputStream fsOut = fs.create(dir,true); 

for (Result row : rows) { 
try { 
String normRow = NormalizeHBaserow(
Bytes.toString(key.getBytes()), row, tableName); 
fsOut.writeBytes(normRow); 

//context.write(new Text(key.toString()), new Text(normRow)); 
    } catch (BadHTableResultException ex) { 
    throw new IOException(ex); 
} 
} 
fsOut.flush();   
fsOut.close(); 

我对减速机的输出配置提前

Path out = new Path(args[0] + "/" + tableName+"Global"); 
FileOutputFormat.setOutputPath(job, out); 

谢谢 - Panks

回答

0

为什么不减少到HDFS,一旦完成使用HDFS FS到导出文件

hadoop fs -get /user/hadoop/file localfile 

如果您确实想要在缩减阶段处理它,请参阅InfoQ上的this article on OutputFormat

相关问题