错误
Mkdirs failed to create /var/folders/md/p3lgpzzj7z9dsjkl6by6mcqr0000gn/T/hadoop-unjar2026375404414126377/META-INF/license
问题
程序打包了一个MapReduce的jar程序,通过hadoop jar xxx.jar
在本地执行,出现上述错误。
原因
在java程序中未设置core-site.xml文件
解决
在程序中添加core-site.xml的配置文件,再次Debug代码时发现,从Configuration类中获取到的fs.defaultFS
为hdfs的了,未配置时获取到的为file:///
,file这样是本地,所以出现了一些意外的错误。
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>