2017-05-27 72 views
1

我在centos7中安裝了Hadoop 2.6並且運行良好。但是,當我從Eclipse運行導出的罐子,它提供了以下錯誤:運行從Eclipse導出的jar時出現InvalidInputException

[[email protected] ~]# hadoop jar fengcount.jar intput output1 
17/05/26 21:24:51 INFO client.RMProxy: Connecting to ResourceManager 
    at myspark/192.168.44.100:8032 17/05/26 21:24:53 INFO mapreduce.JobSubmitter: Cleaning up the staging area /tmp/hadoop-yarn/staging/root/.staging/job_1495765615548_0004 Exception in thread "main" org.apache.hadoop.mapreduce.lib.input.InvalidInputException: Input path does not exist: hdfs://myspark:54310/user/root/intput 
    at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.singleThreadedListStatus(FileInputFormat.java:321) 
    at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.listStatus(FileInputFormat.java:264) 
    at org.apache.hadoop.mapreduce.lib.input.FileInputFormat.getSplits(FileInputFormat.java:385) 
    at org.apache.hadoop.mapreduce.JobSubmitter.writeNewSplits(JobSubmitter.java:302) 
    at org.apache.hadoop.mapreduce.JobSubmitter.writeSplits(JobSubmitter.java:319) 
    at org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:197) 
    at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1297) 
    at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1294) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at javax.security.auth.Subject.doAs(Subject.java:422) 
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1692) 
    at org.apache.hadoop.mapreduce.Job.submit(Job.java:1294) 
    at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:1315) 
    at hdfs.hadoop_hdfs.fengcount.main(fengcount.java:39) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at org.apache.hadoop.util.RunJar.run(RunJar.java:221) 
    at org.apache.hadoop.util.RunJar.main(RunJar.java:136) 

文件輸入/ test1.txt的確實存在:

[[email protected] ~]# hdfs dfs -ls -R 
drwxr-xr-x - root supergroup   0 2017-05-26 21:02 input 
-rw-r--r-- 1 root supergroup   16 2017-05-24 01:57 input/test1.txt 

我的代碼:

package hdfs.hadoop_hdfs; 

import java.io.IOException; 
import java.util.StringTokenizer; 

import org.apache.hadoop.conf.Configuration; 
import org.apache.hadoop.fs.Path; 
import org.apache.hadoop.io.IntWritable; 
import org.apache.hadoop.io.Text; 
import org.apache.hadoop.mapreduce.Job; 
import org.apache.hadoop.mapreduce.Mapper; 
import org.apache.hadoop.mapreduce.Reducer; 
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; 
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; 
import org.apache.hadoop.util.GenericOptionsParser; 



public class fengcount { 

    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException { 
     // TODO Auto-generated method stub 
     Configuration conf=new Configuration(); 
     String[] otherargs=new GenericOptionsParser(conf,args).getRemainingArgs(); 
     if (otherargs.length!=2) { 
      System.err.println("Usage:fengcount<int><out>"); 
      System.exit(2); 
     } 
     @SuppressWarnings("deprecation") 
     Job job=new Job(conf, "fengcount"); 
     job.setJarByClass(fengcount.class); 
     job.setMapperClass(TokerizerMapper.class); 
     job.setCombinerClass(IntSumReducer.class); 
     job.setReducerClass(IntSumReducer.class); 
     job.setOutputKeyClass(Text.class); 
     job.setOutputValueClass(IntWritable.class); 
     FileInputFormat.addInputPath(job, new Path(otherargs[0])); 
     FileOutputFormat.setOutputPath(job, new Path(otherargs[1])); 
     System.exit(job.waitForCompletion(true)?0:1); 

    } 

    // mapper class 
    public static class TokerizerMapper extends Mapper<Object, Text, Text, IntWritable> { 
     private final static IntWritable one = new IntWritable(1); 
     private Text word = new Text(); 

     @Override 
     public void map(Object key, Text value, Context context) throws IOException, InterruptedException { 
      // TODO Auto-generated method stub 
      System.out.println("key=" + key.toString()); 
      System.out.println("value=" + value.toString()); 

      StringTokenizer itr = new StringTokenizer(value.toString()); 
      while (itr.hasMoreTokens()) { 
       word.set(itr.nextToken()); 
       context.write(word, one); 
      } 
     } 
    } 
    //reduce process 
    public static class IntSumReducer extends Reducer<Text, IntWritable, Text, IntWritable> { 
     private IntWritable result = new IntWritable(); 

     @Override 
     public void reduce(Text key, Iterable<IntWritable> values, 
       Reducer<Text, IntWritable, Text, IntWritable>.Context context) 
       throws IOException, InterruptedException { 
      // TODO Auto-generated method stub 
      int sum = 0; 
      for (IntWritable val : values) { 
       sum += val.get(); 
      } 
      result.set(sum); 
      context.write(key, result); 
     } 
    } 
    //mapreduce process 
} 
+0

此路徑是否存在「hdfs:// myspark:54310/user/root/intput」?輸入正確嗎? – harshavmb

+0

是的,它存在。 #hdfs dfs -ls -R drwxr-xr-x - 根超級組0 2017-05-26 21:02輸入 -rw-r - r-- 1根超級組16 2017-04-24 01:57輸入/ test1.txt – fengyue

+0

但在錯誤日誌中看到輸入。你可以檢查它是輸入還是輸入? – harshavmb

回答

0

從錯誤日誌中,我可以看到hdfs://myspark:54310/user/root/intput,我懷疑它的錯誤。我想路徑以input結束。

祝你好運!

+0

謝謝。如你所說。我輸入了輸入。再次感謝您的提醒。 – fengyue