1
맵퍼에서 hadoop 파일 시스템에 일반 텍스트 파일을 직접 쓰려고합니다. 다음과 같이지도에서 hadoop 파일 시스템 (HDFS)에 쓰기가 가능하지 않습니다.
나는 그것을 할 :
public void createFile(Configuration conf) throws IOException{
FileSystem fs = FileSystem.get(conf);
Path filenamePath = new Path(conf.get("mapred.output.dir")+"/_"+conf.get("mapred.task.id"), "tree.txt");
try {
if (fs.exists(filenamePath)) {
// remove the file first
fs.delete(filenamePath);
}
FSDataOutputStream out = fs.create(filenamePath);
out.writeUTF("hello, world!");
out.close();
} catch (IOException ioe) {
System.err.println("IOException during operation: " + ioe.toString());
System.exit(1);
}
}
을 그리고 의사 분산 모드에서 아무것도 기록하지 않습니다. 그러나 독립 실행 형에서는 완벽하게 작성합니다.
어디에 문제가 있습니까?
무엇이 오류입니까? 전달 된'Configuration' 객체가'fs.default.name' 속성을 가지고 있지 않으면이 파일을 HDFS가 아닌 로컬 디스크에 쓸 수 있습니다. –
로깅 문을 코드에 넣고 로그를 확인 했습니까? – dfrankow