[英]How to run a mapreduce job in Hortonworks sandbox Hadoop platform
I am new in Hadoop. 我是Hadoop的新手。 I have installed the oracle virtual box for and mounted the image of hortonworks sandbox in the virtual machine.also i have written the wordcount program in eclipse and trying to run that in the virtual machine.
我已经为虚拟机安装了oracle虚拟框并将hortonworks沙箱的映像安装在虚拟机中。我也在eclipse中编写了wordcount程序,并试图在虚拟机中运行它。 But I am getting an exception tree.
但是我得到了一个异常树。 I am posting the program and the error tree also.
我也在发布程序和错误树。
public class WordCount {
public static class Map extends MapReduceBase implements
Mapper<LongWritable, Text, Text, IntWritable> {
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
public void map(LongWritable key, Text value,
OutputCollector<Text, IntWritable> output, Reporter reporter)
throws IOException {
String line = value.toString();
StringTokenizer tokenizer = new StringTokenizer(line);
while (tokenizer.hasMoreTokens()) {
word.set(tokenizer.nextToken());
output.collect(word, one);
}
}
}
public static class Reduce extends MapReduceBase implements
Reducer<Text, IntWritable, Text, IntWritable> {
public void reduce(Text key, Iterator<IntWritable> values,
OutputCollector<Text, IntWritable> output, Reporter reporter)
throws IOException {
int sum = 0;
while (values.hasNext()) {
sum += values.next().get();
}
output.collect(key, new IntWritable(sum));
}
}
public static void main(String[] args) throws IOException {
JobConf conf = new JobConf(WordCount.class);
conf.setJobName("wordcount");
conf.setOutputKeyClass(Text.class);
conf.setOutputValueClass(IntWritable.class);
conf.setMapperClass(Map.class);
conf.setCombinerClass(Reduce.class);
conf.setReducerClass(Reduce.class);
conf.setInputFormat(TextInputFormat.class);
conf.setOutputFormat(TextOutputFormat.class);
FileInputFormat.setInputPaths(conf, new Path(args[0]));
FileOutputFormat.setOutputPath(conf, new Path(args[1]));
JobClient.runJob(conf);
}
}
[hue@sandbox`]$hadoop jar/usr/lib/wordcount.jar wordcount[-m][-r] [hue @ sandbox`] $ hadoop jar / usr / lib / wordcount.jar wordcount [-m] [-r]
Exception in thread main java.lang.NoClassDefFoundError:jar/usr/lib/wordcount/jar 线程主java.lang.NoClassDefFoundError中的异常:jar / usr / lib / wordcount / jar
caused by:java.lang.ClassNotFoundException:jar.usr.lib.wordcount.jar at java.net.URLClassLoader$1.run(URLlassLoader.java:202) at java.security.AccessController.doPriviledged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Laucher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) 由java.net.URLClassLoader $ 1.run(URLlassLoader.java:202)处的java.net.URL.LoadController.doPriviledged(本机方法)处的java.lang.ClassNotFoundException:jar.usr.lib.wordcount.jar引起.URLClassLoader.findClass(URLClassLoader.java:190)在java.lang.ClassLoader.loadClass(ClassLoader.java:306)在sun.misc.Launcher $ AppClassLoader.loadClass(Laucher.java:301)在java.lang.ClassLoader。 loadClass(ClassLoader.java:247)
could not find the main class:jar/usr/lib/wordcount.jar 找不到主类:jar / usr / lib / wordcount.jar
i am using the Hortonworks+Sandbox+1.3+VirtualBox+RC6 this version on a 64 bit machine . 我在64位计算机上使用Hortonworks + Sandbox + 1.3 + VirtualBox + RC6这个版本。
You're not invoking hadoop correctly, you're missing a space, as well as args. 您没有正确调用hadoop,缺少空格和args。 Try
尝试
hadoop jar /usr/lib/wordcount.jar WordCount <the path to your input file on HDFS> <the path to your output directory on HDFS>
If you get another class not found, try using the full class name of WordCount (eg, com.mysite.WordCount). 如果找不到另一个类,请尝试使用WordCount的完整类名(例如com.mysite.WordCount)。 I can't see what package it's in.
我看不到里面的包裹。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.