分享

运行mapreduce程序报错,求解答

丹青穆怀 发表于 2017-3-9 18:19:51 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 16 12047
hadoop jar ./HadoopTest01.jar cn.dataguru.hadoop.BaseStationDataPreprocess /user/hadoop/file/input /user/hadoop/file/output 2013-09-12 07-09-17-24
17/03/09 18:00:07 INFO impl.TimelineClientImpl: Timeline service address: http://hadoop001:8188/ws/v1/timeline/
17/03/09 18:00:08 INFO client.AHSProxy: Connecting to Application History server at hadoop001/172.16.13.224:10200
Exception in thread "main" org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory hdfs://beh/user/hadoop/file/input already exists
        at org.apache.hadoop.mapreduce.lib.output.FileOutputFormat.checkOutputSpecs(FileOutputFormat.java:146)
        at org.apache.hadoop.mapreduce.JobSubmitter.checkSpecs(JobSubmitter.java:267)
        at org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:140)
        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:1656)
        at org.apache.hadoop.mapreduce.Job.submit(Job.java:1294)
        at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:1315)
        at cn.dataguru.hadoop.BaseStationDataPreprocess.run(BaseStationDataPreprocess.java:233)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
        at cn.dataguru.hadoop.BaseStationDataPreprocess.main(BaseStationDataPreprocess.java:255)
        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)

一直报hdfs://beh/user/hadoop/file/input已经存在,这个里面有数据必须的存在啊,
应该是找不到这个路径吧。

因为我把程序里面的这俩路径写死,就可以了,
FileInputFormat.addInputPath( job, new Path("hadoop001:9000/user/hadoop/file/input") );               
FileOutputFormat.setOutputPath( job, new Path("hadoop001:9000/user/hadoop/file/output") );

可是这样的话是不是就成了单机版的了,不是集群模式了。
该怎么改一下???

已有(16)人评论

跳转到指定楼层
qcbb001 发表于 2017-3-9 21:05:54
hadoop001:9000/user/hadoop/file/input
hdfs://beh/user/hadoop/file/input
进到对应路径,然后删除这个文件,在运行就可以了
回复

使用道具 举报

丹青穆怀 发表于 2017-3-10 09:47:14
qcbb001 发表于 2017-3-9 21:05
hadoop001:9000/user/hadoop/file/input
hdfs://beh/user/hadoop/file/input
进到对应路径,然后删除这 ...

hdfs://beh/user/hadoop/file/input,这个路径直接删除是删除不了了,不存在这个目录,因为前面的beh就代表用户+端口,这个在配置文件里面配置Ha的时候就有,错误时因为命令识别不了beh,可能是没有走配置文件,存在的是/user/hadoop/file/input,如果这个目录删了,数据就没有了。
回复

使用道具 举报

arsenduan 发表于 2017-3-10 10:04:27
丹青穆怀 发表于 2017-3-10 09:47
hdfs://beh/user/hadoop/file/input,这个路径直接删除是删除不了了,不存在这个目录,因为前面的beh就代 ...

Output directory hdfs://beh/user/hadoop/file/input already exists
仔细阅读下源码,输入路径和输出路径弄颠倒了。
回复

使用道具 举报

丹青穆怀 发表于 2017-3-10 14:54:47
arsenduan 发表于 2017-3-10 10:04
Output directory hdfs://beh/user/hadoop/file/input already exists
仔细阅读下源码,输入路径和输出 ...

应该不是这个问题,先写输入,在写输出,然后代码里面,输入路径里面是args[0],输出是args[1],这个没有问题。
回复

使用道具 举报

qcbb001 发表于 2017-3-12 10:00:07
丹青穆怀 发表于 2017-3-10 14:54
应该不是这个问题,先写输入,在写输出,然后代码里面,输入路径里面是args[0],输出是args[1],这个没有 ...

代码贴出来
回复

使用道具 举报

丹青穆怀 发表于 2017-3-13 09:18:02

Configuration conf = getConf();
                //传递任务参数
                conf.set("date", args[2]);
                conf.set("timepoint", args[3]);
                Job job = new Job(conf, "BaseStationDataPreprecess");
                job.setJarByClass(BaseStationDataPreprocess.class);
                //输入路径
                FileInputFormat.addInputPath(job, new Path(args[0]));
                //输出路径
                FileOutputFormat.setOutputPath(job, new Path(args[1]));
                //调用Map类作为Map任务的代码
                job.setMapperClass(Map.class);
                //调用Reduce类作为Reduce任务代码
                job.setReducerClass(Reducer.class);
                //job.setOutputFormatClass(TextOutputFormat.class);
                job.setOutputKeyClass(Text.class);
                job.setOutputValueClass(Text.class);
                //执行任务命令
                job.waitForCompletion(true);

回复

使用道具 举报

einhep 发表于 2017-3-13 10:03:28
丹青穆怀 发表于 2017-3-13 09:18
Configuration conf = getConf();
                //传递任务参数
                conf.set("date", args[2]);

...
关键内容,没有表示出来。

[mw_shl_code=java,true]    //传递任务参数
                conf.set("date", args[2]);
                conf.set("timepoint", args[3]);
   //输入路径
                FileInputFormat.addInputPath(job, new Path(args[0]));
                //输出路径
                FileOutputFormat.setOutputPath(job, new Path(args[1]));[/mw_shl_code]
。。。。。你输入的都看不到,而且是灵活的。
建议楼主参考一些标准的程序。等熟练知识之后,在搞花样。
回复

使用道具 举报

丹青穆怀 发表于 2017-3-14 15:33:54
einhep 发表于 2017-3-13 10:03
...
关键内容,没有表示出来。

输入我上边已经写了,就在最上面。这只是一个简单的小案例,现在应该不是代码的问题,因为单机可以跑,现在集群跑不起来,怀疑是配置出问题了。
回复

使用道具 举报

nextuser 发表于 2017-3-14 16:15:06
丹青穆怀 发表于 2017-3-14 15:33
输入我上边已经写了,就在最上面。这只是一个简单的小案例,现在应该不是代码的问题,因为单机可以跑,现 ...

你怎么提交,贴出图来
回复

使用道具 举报

12下一页
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条