我已经编写了一个 Hadoop map-reduce 程序,现在我想在Cloadera Hadoop 发行版上测试它,该发行版在virtual box的同一台计算机上运行。
以下是我如何提交该 map-reduce 作业:
public class AvgCounter extends Configured implements Tool{
public int run(String[] args) throws Exception {
Job mrJob = Job.getInstance(new Cluster(getConf()), getConf());
mrJob.setJobName("Average count");
mrJob.setJarByClass(AvgCounter.class);
mrJob.setOutputKeyClass(IntWritable.class);
mrJob.setOutputValueClass(Text.class);
mrJob.setMapperClass(AvgCounterMap.class);
mrJob.setCombinerClass(AvgCounterReduce.class);
mrJob.setReducerClass(AvgCounterReduce.class);
mrJob.setInputFormatClass(TextInputFormat.class);
mrJob.setOutputFormatClass(TextOutputFormat.class);
FileInputFormat.setInputPaths(mrJob, new Path("/user/test/testdata.csv"));
FileOutputFormat.setOutputPath(mrJob, new Path("/user/test/result.txt"));
mrJob.setWorkingDirectory(new Path("/tmp"));
return mrJob.waitForCompletion(true)? 1: 0;
}
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
conf.set("fs.defaultFS", "hdfs://192.168.5.50:9000");
conf.set("mapreduce.jobtracker.address", "192.168.5.50:9001");
System.exit(ToolRunner.run(conf, new AvgCounter(), args));
}
}
AvgCounterMap
有map
什么都不做的AvgCounterReduce
空方法和什么都不做的空reduce
方法。当我尝试运行 main 方法时,出现以下异常:
Exception in thread "main" java.io.IOException: Call to /192.168.5.50:9001 failed on local exception: java.io.EOFException
at org.apache.hadoop.ipc.Client.wrapException(Client.java:1063)
at org.apache.hadoop.ipc.Client.call(Client.java:1031)
at org.apache.hadoop.ipc.WritableRpcEngine$Invoker.invoke(WritableRpcEngine.java:198)
at $Proxy0.getProtocolVersion(Unknown Source)
at org.apache.hadoop.ipc.WritableRpcEngine.getProxy(WritableRpcEngine.java:235)
at org.apache.hadoop.ipc.RPC.getProxy(RPC.java:275)
at org.apache.hadoop.ipc.RPC.getProxy(RPC.java:249)
at org.apache.hadoop.mapreduce.Cluster.createRPCProxy(Cluster.java:86)
at org.apache.hadoop.mapreduce.Cluster.createClient(Cluster.java:98)
at org.apache.hadoop.mapreduce.Cluster.<init>(Cluster.java:74)
at eu.xxx.mapred.AvgCounter.run(AvgCounter.java:22)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:69)
at eu.xxx.mapred.AvgCounter.main(AvgCounter.java:53)
Caused by: java.io.EOFException
at java.io.DataInputStream.readInt(DataInputStream.java:375)
at org.apache.hadoop.ipc.Client$Connection.receiveResponse(Client.java:760)
at org.apache.hadoop.ipc.Client$Connection.run(Client.java:698)
运行 Hadoop 的虚拟 Cloudera 机器在文件中有以下内容/etc/hadoop/conf/core.site.xml
<property>
<name>fs.default.name</name>
<value>hdfs://192.168.5.50:9000</value>
</property>
在文件/etc/hadoop/conf/mapred.site.xml
中有
<property>
<name>mapred.job.tracker</name>
<value>192.168.5.50:9001</value>
</property>
92.168.5.50:50030
我还通过写入我的 Web 浏览器检查了与虚拟机的连接,并按预期进行了 Hadoop Map/Reduce 管理。那么导致该异常的原因是什么,我该如何摆脱它呢?
谢谢你的任何想法