hadoop MultipleOutputs 到绝对路径,但其他尝试已创建文件
hadoop MultipleOutputs to absolute path , but file is already being created by other attempt
我使用 MultipleOutputs 将数据输出到一些绝对路径,而不是相对于 OutputPath 的路径。
然后,我得到错误:
Error: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException): Failed to create file [/test/convert.bak/326/201505110030/326-m-00035] for [DFSClient_attempt_1425611626220_29142_m_000035_1001_-370311306_1] on client [192.168.7.146], because this file is already being created by [DFSClient_attempt_1425611626220_29142_m_000035_1000_-53988495_1] on [192.168.7.149] at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.recoverLeaseInternal(FSNamesystem.java:2320) at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.startFileInternal(FSNamesystem.java:2083) at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.startFileInt(FSNamesystem.java:2012) at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.startFile(FSNamesystem.java:1963) at
通过查看堆栈跟踪错误,输出文件似乎已经创建。
如果您想将数据写入多个文件,请尝试动态生成这些文件名并使用这些文件名,如摘自 Hadoop 权威指南的代码所示
String basePath = String.format("%s/%s/part", parser.getStationId(), parser.getYear());
multipleOutputs.write(NullWritable.get(), value, basePath);
希望对您有所帮助。
因为它清楚地表明您要创建的路径已经存在。因此,尝试在创建该路径之前检查该路径是否存在或 not.If 存在,然后删除该路径。
FileSystem hdfs;
Path path = new Path (YourHadoopPath);
if (hdfs.exists(path)) {
hdfs.delete(path);
}
https://issues.apache.org/jira/browse/MAPREDUCE-6357
输出文件必须在${mapred.output.dir}。
设计和实现不支持从 ${mapred.output.dir} 输出数据到文件。
我使用 MultipleOutputs 将数据输出到一些绝对路径,而不是相对于 OutputPath 的路径。
然后,我得到错误:
Error: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException): Failed to create file [/test/convert.bak/326/201505110030/326-m-00035] for [DFSClient_attempt_1425611626220_29142_m_000035_1001_-370311306_1] on client [192.168.7.146], because this file is already being created by [DFSClient_attempt_1425611626220_29142_m_000035_1000_-53988495_1] on [192.168.7.149] at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.recoverLeaseInternal(FSNamesystem.java:2320) at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.startFileInternal(FSNamesystem.java:2083) at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.startFileInt(FSNamesystem.java:2012) at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.startFile(FSNamesystem.java:1963) at
通过查看堆栈跟踪错误,输出文件似乎已经创建。
如果您想将数据写入多个文件,请尝试动态生成这些文件名并使用这些文件名,如摘自 Hadoop 权威指南的代码所示
String basePath = String.format("%s/%s/part", parser.getStationId(), parser.getYear());
multipleOutputs.write(NullWritable.get(), value, basePath);
希望对您有所帮助。
因为它清楚地表明您要创建的路径已经存在。因此,尝试在创建该路径之前检查该路径是否存在或 not.If 存在,然后删除该路径。
FileSystem hdfs;
Path path = new Path (YourHadoopPath);
if (hdfs.exists(path)) {
hdfs.delete(path);
}
https://issues.apache.org/jira/browse/MAPREDUCE-6357
输出文件必须在${mapred.output.dir}。
设计和实现不支持从 ${mapred.output.dir} 输出数据到文件。