Hadoop java.io.IOException:Mkdirs无法创建/ some / path

时间:2012-05-09 19:29:09

标签: hadoop ioexception dfs

当我尝试运行我的工作时,我遇到以下异常:

Exception in thread "main" java.io.IOException: Mkdirs failed to create /some/path
    at org.apache.hadoop.util.RunJar.ensureDirectory(RunJar.java:106)
    at org.apache.hadoop.util.RunJar.main(RunJar.java:150)

/ some / path是hadoop.tmp.dir。但是,当我在/ some / path上发出dfs -ls cmd时,我可以看到它存在并且数据集文件存在(在午餐之前复制了该文件)。此外,路径在hadoop配置中正确定义。任何建议将不胜感激。我正在使用hadoop 0.21。

8 个答案:

答案 0 :(得分:86)

在我的MacBook Air中以独立模式从CDH4运行mahout遇到了这个问题。

问题是在解除mahout作业时,在不区分大小写的文件系统上创建了/ tmp / hadoop-xxx / xxx / LICENSE文件和/ tmp / hadoop-xxx / xxx / license目录。

我可以通过从jar文件中删除META-INF / LICENSE来解决此问题:

zip -d mahout-examples-0.6-cdh4.0.0-job.jar META-INF/LICENSE

然后用

验证它
jar tvf mahout-examples-0.6-cdh4.0.0-job.jar | grep -i license

希望这有帮助!

答案 1 :(得分:13)

问题是OSX特定的,因为默认情况下文件系统设置为 Mac上的不区分大小写的(案例保留但不区分大小写,我认为非常糟糕)。

要避免这种情况的黑客攻击是使用磁盘实用程序创建一个区分大小写的.dmg磁盘映像,并将此映像挂载到您需要的位置(即hadoop.tmp.dir或/ tmp)以下命令(作为超级用户):

sudo hdiutil attach -mountpoint /tmp <my_image>.dmg

我希望它有所帮助。

答案 2 :(得分:11)

我过去曾多次遇到过这个问题,我相信这是Mac特有的问题。由于我使用Maven来构建我的项目,我可以通过在我的Maven pom.xml中添加一行来解决它:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.0</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
            <configuration>
                <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer">
                    </transformer>
                </transformers>
            </configuration>
        </execution>
    </executions>
</plugin>

答案 3 :(得分:9)

这是正在创建的本地磁盘上的文件(将作业jar解压缩到),而不是HDFS中的文件。检查你是否有权使用mkdir这个目录(从命令行试试)

答案 4 :(得分:8)

在我的情况下,Maven项目中pom.xml中的代码行在Mac上工作。

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.0</version>
    <configuration>
      <shadedArtifactAttached>true</shadedArtifactAttached>
    </configuration>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>shade</goal>
        </goals>
          <configuration>
            <filters>
              <filter>
                <artifact>*:*</artifact>
                <excludes>
                  <exclude>META-INF/*.SF</exclude>
                  <exclude>META-INF/*.DSA</exclude>
                  <exclude>META-INF/*.RSA</exclude>
                  <exclude>META-INF/LICENSE*</exclude>
                  <exclude>license/*</exclude>
                </excludes>
              </filter>
            </filters>
        </configuration>
      </execution>
    </executions>
  </plugin>

答案 5 :(得分:2)

检查所需空间是否可用。 由于空间问题,这主要是问题所在。

答案 6 :(得分:2)

我在使用MacOS Sierra在Mac上构建MapReduce作业时遇到了同样的问题。在Ubuntu Linux(14.04 LTS和16.04 LTS)上运行相同的代码没有问题。 MapReduce分布为2.7.3,并配置为单节点独立操作。该问题似乎与将许可证文件复制到META_INF目录有关。我的问题通过在Maven Shade插件配置中添加一个变换器来解决,特别是:ApacheLicenseResourceTransformer

以下是POM.xml的相关部分,它是<build>部分的一部分:

<plugin>                                                                                                             <groupId>org.apache.maven.plugins</groupId>                                                                      
   <artifactId>maven-shade-plugin</artifactId>                                                                      
   <version>3.0.0</version>                                                                                         
   <executions>                                                                                                     
     <execution>                                                                                                    
       <phase>package</phase>                                                                                       
       <goals>                                                                                                      
         <goal>shade</goal>                                                                                         
       </goals>                                                                                                     
       <configuration>                                                                                              
         <transformers>                                                                                             
           <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">       
             <mainClass>path.to.your.main.class.goes.here</mainClass>                                        
           </transformer>                                                                                           
           <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer">  
           </transformer>                                                                                           
         </transformers>                                                                                            
       </configuration>                                                                                             
     </execution>                                                                                                   
   </executions>                                                                                                    
 </plugin>  

请注意,我还使用ManifestResourceTransformer指定MapReduce作业的主类。

答案 7 :(得分:0)

在我的情况下,我刚刚重命名了文件“log_test.txt”

因为OS(UBUNTU)正在尝试生成具有相同名称的文件夹。 “log_test.txt / __ results.json”