当我运行hadoop代码添加第三个jar时,就像下面的代码一样:
public static void addTmpJar(String jarPath, JobConf conf) throws IOException {
System.setProperty("path.separator", ":");
FileSystem fs = FileSystem.getLocal(conf);
String newJarPath = new Path(jarPath).makeQualified(fs).toString();
String tmpjars = conf.get("tmpjars");
if (tmpjars == null || tmpjars.length() == 0) {
conf.set("tmpjars", newJarPath);
} else {
conf.set("tmpjars", tmpjars + "," + newJarPath);
}
}
我得到以下异常:
Error initializing attempt_201405281453_0053_m_000002_0:
org.apache.hadoop.util.DiskChecker $ DiskErrorException:找不到taskTracker / hadoop / distcache / -7315515059647727905_-860888033_1107570546 / nn.hadoop.dev / tmp / hadoop-hadoop / mapred / staging /的任何有效本地目录的hadoop / .staging / job_201405281453_0053 / libjars /象夫核-0.8-job.jar at org.apache.hadoop.fs.LocalDirAllocator $ AllocatorPerContext.getLocalPathForWrite(LocalDirAllocator.java:381) at org.apache.hadoop.fs.LocalDirAllocator.getLocalPathForWrite(LocalDirAllocator.java:146) at org.apache.hadoop.filecache.TrackerDistributedCacheManager.getLocalCache(TrackerDistributedCacheManager.java:173) at org.apache.hadoop.filecache.TaskDistributedCacheManager.setupCache(TaskDistributedCacheManager.java:187) 在org.apache.hadoop.mapred.TaskTracker $ 4.run(TaskTracker.java:1320) at java.security.AccessController.doPrivileged(Native Method) 在javax.security.auth.Subject.doAs(Subject.java:415) 在org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1190) 在org.apache.hadoop.mapred.TaskTracker.initializeJob(TaskTracker.java:1311) 在org.apache.hadoop.mapred.TaskTracker.localizeJob(TaskTracker.java:1226) 在org.apache.hadoop.mapred.TaskTracker $ 5.run(TaskTracker.java:2603) 在java.lang.Thread.run(Thread.java:744)
任何能告诉你如何解决这个问题的人,谢谢!
答案 0 :(得分:0)
从命令行可以使用-libjars
将jar添加到distributedcache,唯一的先决条件是你的MR程序实现了使用GenericOptionsParser的Tool,后者负责将jar添加到缓存中。