---
title: "MapReduce运行异常-- org.apache.hadoop.mapred.FileAlreadyExistsException"
author: "notejs"
date: "2014-03-30T14:55:59Z"
tags: []
categories: ["Web前端"]
slug: "mapreduce-org-apache-hadoop-mapred-filealreadyexistsexception"
draft: false
lastmod: "2014-03-30T14:55:59Z"
id: 2038503
url: "https://notejs.iteye.com/blog/2038503"
---

# [MapReduce运行异常-- org.apache.hadoop.mapred.FileAlreadyExistsException](http://mojijs.com/2014/03/131026/index.html)

**描述**： 输出文件已经存在

**异常**：

14/03/26 23:00:52 WARN mapred.JobClient: No job jar file set. User classes may not be found. See JobConf(Class) or JobConf#setJar(String).

14/03/26 23:00:52 INFO mapred.JobClient: Cleaning up the staging area hdfs://xxx/opt/liveEpg/hadoop/hadoop\_tmp/hadoop\_hadoop/mapred/staging/allen/.staging/job\_201312291735\_0013

14/03/26 23:00:52 ERROR security.UserGroupInformation: PriviledgedActionException as:allen**cause:org.apache.hadoop.mapred.FileAlreadyExistsException**: Output directory hdfs://xxx/mr/sort/sort\_out already exists

Exception in thread "main" org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory hdfs://xxx/mr/sort/sort\_out already exists

at org.apache.hadoop.mapreduce.lib.output.FileOutputFormat.checkOutputSpecs(FileOutputFormat.java:137)

at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:887)

at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:850)

at java.security.AccessController.doPrivileged(Native Method)

at javax.security.auth.Subject.doAs(Subject.java:396)

at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1121)

at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:850)

at org.apache.hadoop.mapreduce.Job.submit(Job.java:500)

at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:530)

at smiple.Sort.main(Sort.java:84)

**解决办法:**

将输出目录中相关文件删除，我一般直接将输出目录删了

**命令**：hadoop fs -rmr /mr/sort/sort\_out