Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
运行从Eclipse导出的jar时InvalidInputException_Eclipse_Hadoop_Jar - Fatal编程技术网

运行从Eclipse导出的jar时InvalidInputException

运行从Eclipse导出的jar时InvalidInputException,eclipse,hadoop,jar,Eclipse,Hadoop,Jar,我已经在centos7中安装了Hadoop 2.6,并且运行良好。但是,当我运行从Eclipse导出的jar时,会出现以下错误: [root@myspark ~]# 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

我已经在centos7中安装了Hadoop 2.6,并且运行良好。但是,当我运行从Eclipse导出的jar时,会出现以下错误:

[root@myspark ~]# 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)
文件input/test1.txt实际上存在:

[root@myspark ~]# 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
}
package hdfs.hadoop\u hdfs;
导入java.io.IOException;
导入java.util.StringTokenizer;
导入org.apache.hadoop.conf.Configuration;
导入org.apache.hadoop.fs.Path;
导入org.apache.hadoop.io.IntWritable;
导入org.apache.hadoop.io.Text;
导入org.apache.hadoop.mapreduce.Job;
导入org.apache.hadoop.mapreduce.Mapper;
导入org.apache.hadoop.mapreduce.Reducer;
导入org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
导入org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
导入org.apache.hadoop.util.GenericOptionsParser;
公营班次{
公共静态void main(字符串[]args)引发IOException、ClassNotFoundException、InterruptedException{
//TODO自动生成的方法存根
Configuration conf=新配置();
String[]otherargs=新的GenericOptionsParser(conf,args);
如果(其他参数长度!=2){
System.err.println(“用法:fengcount”);
系统出口(2);
} 
@抑制警告(“弃用”)
作业作业=新作业(配置,“数量”);
job.setJarByClass(fengcount.class);
setMapperClass(TokerizerMapper.class);
job.setCombinerClass(IntSumReducer.class);
job.setReducerClass(IntSumReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
addInputPath(作业,新路径(其他参数[0]);
setOutputPath(作业,新路径(其他参数[1]);
系统退出(作业等待完成(真)?0:1;
}
//映射器类
公共静态类TokerMapper扩展映射器{
私有最终静态IntWritable one=新的IntWritable(1);
私有文本字=新文本();
@凌驾
公共void映射(对象键、文本值、上下文上下文)引发IOException、InterruptedException{
//TODO自动生成的方法存根
System.out.println(“key=“+key.toString());
System.out.println(“value=“+value.toString());
StringTokenizer itr=新的StringTokenizer(value.toString());
而(itr.hasMoreTokens()){
set(itr.nextToken());
上下文。写(单词,一);
}
}
}
//还原过程
公共静态类IntSumReducer扩展了Reducer{
私有IntWritable结果=新的IntWritable();
@凌驾
public void reduce(文本键、Iterable值、,
(上下文)
抛出IOException、InterruptedException{
//TODO自动生成的方法存根
整数和=0;
for(可写入值:值){
sum+=val.get();
}
结果集(总和);
编写(键、结果);
}
}
//mapreduce进程
}

从错误日志中,我可以看到
hdfs://myspark:54310/user/root/intput
,我怀疑它不正确。我猜路径以
input
结束


祝你好运

从错误日志中,我可以看到
hdfs://myspark:54310/user/root/intput
,我怀疑它不正确。我猜路径以
input
结束


祝你好运

“这条路”hdfs://myspark:54310/user/root/intput“存在吗?输入是正确的??是的。它是存在的#hdfs dfs-ls-R drwxr-xr-x-根超级组0 2017-05-26 21:02输入-rw-R--R--1根超级组16 2017-05-24 01:57输入/测试1.TXT但在错误日志中看到输入。你能检查一下是输入还是输入吗?谢谢。问题已经解决了。正如您所说,我在intput中输入了input。是否使用此路径“hdfs://myspark:54310/user/root/intput“存在吗?输入是正确的??是的。它是存在的#hdfs dfs-ls-R drwxr-xr-x-根超级组0 2017-05-26 21:02输入-rw-R--R--1根超级组16 2017-05-24 01:57输入/测试1.TXT但在错误日志中看到输入。你能检查一下是输入还是输入吗?谢谢。问题已经解决了。正如您所说,我已将输入输入到intput。谢谢。正如你所说。我输入输入到输入。再次感谢您的提醒。谢谢。正如你所说。我输入输入到输入。再次感谢您的提醒。