Hadoop java.io.IOException:Mkdirs 未能创建 /some/path



当我尝试运行作业时,出现以下异常:

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。

在我的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

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

规避此问题的技巧是使用区分大小写的磁盘实用程序创建一个.dmg磁盘映像,并使用以下命令(作为超级用户)将此映像挂载到您需要的位置(即hadoop.tmp.dir或/tmp):

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

我希望它有所帮助。

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

我过去多次遇到此问题,我相信这是 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>

在我的例子中,pom中的代码行.xml在Maven项目中在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>

检查所需空间是否可用。这是问题主要是因为空间问题。

我在MacOS Sierra上构建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 作业的主类。

就我而言,我只是将文件重命名为"log_test.txt"

因为操作系统(UBUNTU)正在尝试生成具有相同名称的文件夹。"log_test.txt/__results.json"

相关内容

最新更新