我安装了Cloudera Manager,并将2个节点连接到一个主节点。我正在尝试使用cloudera在以下链接提供的教程来运行wordcount程序:
https://ccp.cloudera.com/display/SUPPORT/Hadoop+Tutorial#HadoopTutorial-InputsandOutputs

Cloudera说要编译我在命令提示符下使用nano创建的WordCount.java文件。然后创建目录Wordcount_Classes并将wordcount.java文件放入其中。我不知道该目录是否应该移动到cloudera目录之一中的某个位置以便Java代码起作用?或者,如果我做错了其他事情。我安装了Cloudera Manager,它已经自动在所有节点上安装了ClouderaHadoop。我在终端上得到这个:

mark@*****:~/wordcount_classes$ javac WordCount.java
WordCount.java:6: package org.apache.hadoop.fs does not exist
import org.apache.hadoop.fs.Path;
                           ^
WordCount.java:7: package org.apache.hadoop.conf does not exist
import org.apache.hadoop.conf.*;
^
WordCount.java:8: package org.apache.hadoop.io does not exist
import org.apache.hadoop.io.*;
^
WordCount.java:9: package org.apache.hadoop.mapred does not exist
import org.apache.hadoop.mapred.*;
^
WordCount.java:10: package org.apache.hadoop.util does not exist
import org.apache.hadoop.util.*;
^
WordCount.java:14: cannot find symbol
symbol  : class MapReduceBase
location: class org.myorg.WordCount
  public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> {
                                  ^
WordCount.java:14: cannot find symbol
symbol  : class Mapper
location: class org.myorg.WordCount
  public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> {
                                                           ^
WordCount.java:14: cannot find symbol
symbol  : class LongWritable
location: class org.myorg.WordCount
  public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> {
                                                                  ^
WordCount.java:14: cannot find symbol
symbol  : class Text
location: class org.myorg.WordCount
  public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> {
                                                                                ^
WordCount.java:14: cannot find symbol
symbol  : class Text
location: class org.myorg.WordCount
  public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> {
                                                                                      ^
WordCount.java:14: cannot find symbol
symbol  : class IntWritable
location: class org.myorg.WordCount
  public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> {
                                                                                            ^
WordCount.java:14: interface expected here
  public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> {
                                                                 ^
WordCount.java:15: cannot find symbol
symbol  : class IntWritable
location: class org.myorg.WordCount.Map
    private final static IntWritable one = new IntWritable(1);
                         ^
WordCount.java:16: cannot find symbol
symbol  : class Text
location: class org.myorg.WordCount.Map
    private Text word = new Text();
            ^
WordCount.java:18: cannot find symbol
symbol  : class LongWritable
location: class org.myorg.WordCount.Map
    public void map(LongWritable key, Text value, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
                    ^
WordCount.java:18: cannot find symbol
symbol  : class Text
location: class org.myorg.WordCount.Map
    public void map(LongWritable key, Text value, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
                                      ^
WordCount.java:18: cannot find symbol
symbol  : class OutputCollector
location: class org.myorg.WordCount.Map
    public void map(LongWritable key, Text value, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
                                                  ^
WordCount.java:18: cannot find symbol
symbol  : class Text
location: class org.myorg.WordCount.Map
    public void map(LongWritable key, Text value, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
                                                                  ^
WordCount.java:18: cannot find symbol
symbol  : class IntWritable
location: class org.myorg.WordCount.Map
    public void map(LongWritable key, Text value, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
                                                                        ^
WordCount.java:18: cannot find symbol
symbol  : class Reporter
location: class org.myorg.WordCount.Map
    public void map(LongWritable key, Text value, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
                                                                                             ^
WordCount.java:28: cannot find symbol
symbol  : class MapReduceBase
location: class org.myorg.WordCount
  public static class Reduce extends MapReduceBase implements Reducer<Text, IntWritable, Text, IntWritable> {
                                     ^
WordCount.java:28: cannot find symbol
symbol  : class Reducer
location: class org.myorg.WordCount
  public static class Reduce extends MapReduceBase implements Reducer<Text, IntWritable, Text, IntWritable> {
                                                              ^
WordCount.java:28: cannot find symbol
symbol  : class Text
location: class org.myorg.WordCount
  public static class Reduce extends MapReduceBase implements Reducer<Text, IntWritable, Text, IntWritable> {
                                                                      ^
WordCount.java:28: cannot find symbol
symbol  : class IntWritable
location: class org.myorg.WordCount
  public static class Reduce extends MapReduceBase implements Reducer<Text, IntWritable, Text, IntWritable> {
                                                                            ^
WordCount.java:28: cannot find symbol
symbol  : class Text
location: class org.myorg.WordCount
  public static class Reduce extends MapReduceBase implements Reducer<Text, IntWritable, Text, IntWritable> {
                                                                                         ^
WordCount.java:28: cannot find symbol
symbol  : class IntWritable
location: class org.myorg.WordCount
  public static class Reduce extends MapReduceBase implements Reducer<Text, IntWritable, Text, IntWritable> {
                                                                                               ^
WordCount.java:28: interface expected here
  public static class Reduce extends MapReduceBase implements Reducer<Text, IntWritable, Text, IntWritable> {
                                                                     ^
WordCount.java:29: cannot find symbol
symbol  : class Text
location: class org.myorg.WordCount.Reduce
    public void reduce(Text key, Iterator<IntWritable> values, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
                       ^
WordCount.java:29: cannot find symbol
symbol  : class IntWritable
location: class org.myorg.WordCount.Reduce
    public void reduce(Text key, Iterator<IntWritable> values, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
                                          ^
WordCount.java:29: cannot find symbol
symbol  : class OutputCollector
location: class org.myorg.WordCount.Reduce
    public void reduce(Text key, Iterator<IntWritable> values, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
                                                               ^
WordCount.java:29: cannot find symbol
symbol  : class Text
location: class org.myorg.WordCount.Reduce
    public void reduce(Text key, Iterator<IntWritable> values, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
                                                                               ^
WordCount.java:29: cannot find symbol
symbol  : class IntWritable
location: class org.myorg.WordCount.Reduce
    public void reduce(Text key, Iterator<IntWritable> values, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
                                                                                     ^
WordCount.java:29: cannot find symbol
symbol  : class Reporter
location: class org.myorg.WordCount.Reduce
    public void reduce(Text key, Iterator<IntWritable> values, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
                                                                                                          ^
WordCount.java:15: cannot find symbol
symbol  : class IntWritable
location: class org.myorg.WordCount.Map
    private final static IntWritable one = new IntWritable(1);
                                               ^
WordCount.java:16: cannot find symbol
symbol  : class Text
location: class org.myorg.WordCount.Map
    private Text word = new Text();
                            ^
WordCount.java:32: operator + cannot be applied to int,IntWritable.get
        sum += values.next().get();
            ^
WordCount.java:32: inconvertible types
found   : <nulltype>
required: int
        sum += values.next().get();
                                ^
WordCount.java:34: cannot find symbol
symbol  : class IntWritable
location: class org.myorg.WordCount.Reduce
      output.collect(key, new IntWritable(sum));
                              ^
WordCount.java:39: cannot find symbol
symbol  : class JobConf
location: class org.myorg.WordCount
    JobConf conf = new JobConf(WordCount.class);
    ^
WordCount.java:39: cannot find symbol
symbol  : class JobConf
location: class org.myorg.WordCount
    JobConf conf = new JobConf(WordCount.class);
                       ^
WordCount.java:42: cannot find symbol
symbol  : class Text
location: class org.myorg.WordCount
    conf.setOutputKeyClass(Text.class);
                           ^
WordCount.java:43: cannot find symbol
symbol  : class IntWritable
location: class org.myorg.WordCount
    conf.setOutputValueClass(IntWritable.class);
                             ^
WordCount.java:49: cannot find symbol
symbol  : class TextInputFormat
location: class org.myorg.WordCount
    conf.setInputFormat(TextInputFormat.class);
                        ^
WordCount.java:50: cannot find symbol
symbol  : class TextOutputFormat
location: class org.myorg.WordCount
    conf.setOutputFormat(TextOutputFormat.class);
                         ^
WordCount.java:52: cannot find symbol
symbol  : class Path
location: class org.myorg.WordCount
    FileInputFormat.setInputPaths(conf, new Path(args[0]));
                                            ^
WordCount.java:52: cannot find symbol
symbol  : variable FileInputFormat
location: class org.myorg.WordCount
    FileInputFormat.setInputPaths(conf, new Path(args[0]));
    ^
WordCount.java:53: cannot find symbol
symbol  : class Path
location: class org.myorg.WordCount
    FileOutputFormat.setOutputPath(conf, new Path(args[1]));
                                             ^
WordCount.java:53: cannot find symbol
symbol  : variable FileOutputFormat
location: class org.myorg.WordCount
    FileOutputFormat.setOutputPath(conf, new Path(args[1]));
    ^
WordCount.java:55: cannot find symbol
symbol  : variable JobClient
location: class org.myorg.WordCount
    JobClient.runJob(conf);
    ^
49 errors

有人可以帮助我运行wordcount程序或指导我该怎么做,或者如果有人知道我找不到一个很好的在线教程吗?谢谢!

最佳答案

您需要javac的类路径上的依赖项(对应于import语句)。

使用Hadoop,这可以通过hadoop classpath实用程序更轻松地实现:

$ javac -classpath `hadoop classpath`:. WordCount.java

正确设置类路径后,就不会出现cannot find symbol类的任何编译问题。

关于java - Cloudera Manager 4.0字数示例,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12373277/

10-16 02:46