Edit: IDE is Intellij IDEA
OS: Mac OS X Lion
Hadoop: 1.2.1
編輯:如果文件路徑存在於當前文件系統位置,則可以使用。 因此,當從IDE運行時,如何讓它與hdfs一起工作。從內部IDE運行時出現Hadoop路徑異常
從內部IDE(IntelliJ IDEA的)變得異常運行,見下圖:
在程序參數我指定的「輸入輸出」
當然「輸入」 HDFS中確實存在的數據文件中的IT 。
但代碼試圖從HDFS中訪問目錄形式的本地項目文件系統 位置。
HDFS命令:
James-MacBook-Pro:conf james$ hadoop fs -ls input
Found 1 items
-rw-r--r-- 1 james supergroup 15 2013-11-01 07:31 /user/james/input/simple.txt
的Java源代碼:
public class WordCount extends Configured implements Tool {
public static void main(String[] args) throws Exception {
int res = ToolRunner.run(new Configuration(), new WordCount(), args);
System.exit(res);
}
@Override
public int run(String[] args) throws Exception {
if (args.length != 2) {
System.err.println("Usage: hadoop jar mrjob-1.0-SNAPSHOT-job.jar"
+ " [generic options] <in> <out>");
System.out.println();
ToolRunner.printGenericCommandUsage(System.err);
return 1;
}
Job job = new Job(getConf(), "WordCount");
job.setJarByClass(getClass());
job.setMapperClass(TokenizingMapper.class);
job.setCombinerClass(IntSumReducer.class);
job.setReducerClass(IntSumReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
boolean success = job.waitForCompletion(true);
return success ? 0 : 1;
}
}
配置:
芯-site.xml中
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
HDFS-site.xml中
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
mapred-site.xml中
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>localhost:9001</value>
</property>
</configuration>
參數在IDE:
input output
例外:
Nov 03, 2013 9:46:00 AM org.apache.hadoop.security.UserGroupInformation doAs
SEVERE: PriviledgedActionException as:james cause:org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist: file:/Users/james/work/projects/hadoop/mrjob/input
Exception in thread "main" org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist: file:/Users/james/work/projects/hadoop/mrjob/input
我做了什麼錯?
能否請您發佈自己嘗試過的代碼?有人會幫助你。謝謝。 –
@SSaikia_JtheRocker謝謝,代碼包括在請求。 – jakstack