我有一个自己制作的jar文件"Tsp.jar".这个相同的jar文件在hadoop的单节点集群设置中执行良好.然而,当我在包含2台机器,笔记本电脑和台式机的集群上运行它时,当地图功能达到50%时,它会给我一个例外.这是输出
`hadoop@psycho-O:/usr/local/hadoop$ bin/hadoop jar Tsp.jar clust-Tsp_ip1 clust_Tsp_op4 11/04/27 16:13:06 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same. 11/04/27 16:13:06 WARN mapred.JobClient: No job jar file set. User classes may not be found. See JobConf(Class) or JobConf#setJar(String). 11/04/27 16:13:06 INFO mapred.FileInputFormat: Total input paths to process : 1 11/04/27 16:13:06 INFO mapred.JobClient: Running job: job_201104271608_0001 11/04/27 16:13:07 INFO mapred.JobClient: map 0% reduce 0% 11/04/27 16:13:17 INFO mapred.JobClient: map 50% reduce 0% 11/04/27 16:13:20 INFO mapred.JobClient: Task Id : attempt_201104271608_0001_m_000001_0, Status : FAILED java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassNotFoundException: Tsp$TspReducer at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:841) at org.apache.hadoop.mapred.JobConf.getCombinerClass(JobConf.java:853) at org.apache.hadoop.mapred.Task$CombinerRunner.create(Task.java:1100) at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.(MapTask.java:812) at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:350) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:307) at org.apache.hadoop.mapred.Child.main(Child.java:170) Caused by: java.lang.RuntimeException: java.lang.ClassNotFoundException: Tsp$TspReducer at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:809) at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:833) ... 6 more Caused by: java.lang.ClassNotFoundException: Tsp$TspReducer at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:247) at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:762) at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:807) ... 7 more 11/04/27 16:13:20 WARN mapred.JobClient: Error reading task outputemil-desktop 11/04/27 16:13:20 WARN mapred.JobClient: Error reading task outputemil-desktop ^Z [1]+ Stopped bin/hadoop jar Tsp.jar clust-Tsp_ip1 clust_Tsp_op4 hadoop@psycho-O:~$ jps 4937 Jps 3976 RunJar
`其他群集在执行wordcount示例时运行良好.所以我猜它是Tsp.jar文件的问题.
1)是否有必要在群集上运行jar文件?
2)这里我尝试在我创建的集群中运行一个jar文件.但是仍然发出一个没有找到jar文件的警告.这是为什么?
3)运行jar文件时应该注意什么?就像我写的程序一样,它必须包含什么?我的jar文件包含一个Tsp.class,Tsp $ TspReducer.class和一个Tsp $ TspMapper.class.终端说,当它已经存在于jar文件中时,它无法找到Tsp $ TspReducer.
谢谢
编辑
public class Tsp { public static void main(String[] args) throws IOException { JobConf conf = new JobConf(Tsp.class); conf.setJobName("Tsp"); conf.setOutputKeyClass(Text.class); conf.setOutputValueClass(Text.class); conf.setMapperClass(TspMapper.class); conf.setCombinerClass(TspReducer.class); conf.setReducerClass(TspReducer.class); FileInputFormat.addInputPath(conf,new Path(args[0])); FileOutputFormat.setOutputPath(conf,new Path(args[1])); JobClient.runJob(conf); } public static class TspMapper extends MapReduceBase implements Mapper{ function findCost() { } public void map(LongWritable key,Text value, OutputCollector output, Reporter reporter) throws IOException { find adjacency matrix from the input; for(int i = 0; ...) { ..... output.collect(new Text(string1), new Text(string2)); } } } public static class TspReducer extends MapReduceBase implements Reducer { Text t1 = new Text(); public void reduce(Text key, Iterator values, OutputCollector output, Reporter reporter) throws IOException { String a; a = values.next().toString(); output.collect(key,new Text(a)); } } }
QuinnG.. 7
你现在有
conf.setJobName("Tsp"); conf.setOutputKeyClass(Text.class); conf.setOutputValueClass(Text.class); conf.setMapperClass(TspMapper.class); conf.setCombinerClass(TspReducer.class); conf.setReducerClass(TspReducer.class);
并且因为错误说明No job jar file set
你没有设置一个罐子.
你需要类似的东西
conf.setJarByClass(Tsp.class);
从我所看到的,这应该解决这里看到的错误.
你现在有
conf.setJobName("Tsp"); conf.setOutputKeyClass(Text.class); conf.setOutputValueClass(Text.class); conf.setMapperClass(TspMapper.class); conf.setCombinerClass(TspReducer.class); conf.setReducerClass(TspReducer.class);
并且因为错误说明No job jar file set
你没有设置一个罐子.
你需要类似的东西
conf.setJarByClass(Tsp.class);
从我所看到的,这应该解决这里看到的错误.