我在同一hdfs文件系统中运行一个简单的wordcount程序并获得良好的输出。但是我需要将输出文件放在本地系统中,例如:c:/filename.txt。但是在尝试这样
conf.setInputFormat(TextInputFormat.class);
conf.setOutputFormat(TextOutputFormat.class);
FileInputFormat.setInputPaths(conf, new Path("Input"));
FileOutputFormat.setOutputPath(conf, new Path("c:/filename.txt"));
我收到以下错误:
14/03/03 23:04:32 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.
java.lang.IllegalArgumentException: Pathname /c:/filename.txt from hdfs://localhost:5050/c:/filename.txt is not a valid DFS filename.
at org.apache.hadoop.hdfs.DistributedFileSystem.getPathName(DistributedFileSystem.java:151)
at org.apache.hadoop.hdfs.DistributedFileSystem.getFileStatus(DistributedFileSystem.java:411)
at org.apache.hadoop.fs.FileSystem.exists(FileSystem.java:651)
at org.apache.hadoop.mapred.FileOutputFormat.checkOutputSpecs(FileOutputFormat.java:110)
at org.apache.hadoop.mapred.JobClient.submitJob(JobClient.java:793)
at org.apache.hadoop.mapred.JobClient.runJob(JobClient.java:1142)
at org.raj.MapReduceDriver.main(MapReduceDriver.java:52)
如果可以的话,这有可能吗?
最佳答案
您不能通过MapReduce程序将输出文件放在本地文件系统上。输出路径应设置为HDFS上的目录。
您可以使用hadoop -getmerge <outputDir> <path in Local FS>
命令将输出目录复制到本地FS
关于java - hdfs://localhost:5050/c:/filename.txt中的路径名/c:/filename.txt不是有效的DFS文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22153829/