问题描述:
输入两个文件:
第一个文件内容:Hello World Bye World 
第二个文件内容:Hello Hadoop Goodbye Hadoop are ate
运行WordCount程序的输出内容:却是以上两行!
Hello Hadoop Goodbye Hadoop are ate
Hello World Bye World
----------------------------------------------------------------------------------
WordCount程序应该没问题,应为之前运行正常呢,今天忽然间运行不正常,感觉像Mapper,Reducer不工作了,真心不知道咋回事!本想看看hadoop进程运行是否正常,可是进入hadoop的安装目录bin文件夹后,它竟然说jps命令找不到!
控制台打印的部分信息是:
13/10/02 21:35:43 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
13/10/02 21:35:43 WARN mapred.JobClient: No job jar file set.  User classes may not be found. See JobConf(Class) or JobConf#setJar(String).
13/10/02 21:35:43 INFO input.FileInputFormat: Total input paths to process : 2
13/10/02 21:35:43 WARN snappy.LoadSnappy: Snappy native library not loaded
13/10/02 21:35:44 INFO mapred.JobClient: Running job: job_local255489033_0001
13/10/02 21:35:44 INFO mapred.LocalJobRunner: Waiting for map tasks
13/10/02 21:35:44 INFO mapred.LocalJobRunner: Starting task: attempt_local255489033_0001_m_000000_0
13/10/02 21:35:44 INFO util.ProcessTree: setsid exited with exit code 0
13/10/02 21:35:44 INFO mapred.Task:  Using ResourceCalculatorPlugin : org.apache.hadoop.util.LinuxResourceCalculatorPlugin@58dad8b5
13/10/02 21:35:44 INFO mapred.MapTask: Processing split: hdfs://localhost:9000/user/test/input/2.txt:0+36
13/10/02 21:35:44 INFO mapred.MapTask: io.sort.mb = 100
13/10/02 21:35:45 INFO mapred.MapTask: data buffer = 79691776/99614720
13/10/02 21:35:45 INFO mapred.MapTask: record buffer = 262144/327680

解决方案 »

  1.   


    package testpkg;import java.io.IOException;
    import java.util.StringTokenizer;import org.apache.hadoop.conf.Configuration;
    import org.apache.hadoop.fs.Path;
    import org.apache.hadoop.io.IntWritable;
    import org.apache.hadoop.io.Text;
    import org.apache.hadoop.mapreduce.Job;
    import org.apache.hadoop.mapreduce.Mapper;
    import org.apache.hadoop.mapreduce.Reducer;
    import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
    import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
    import org.apache.hadoop.util.GenericOptionsParser;public class WordCount {  public static class TokenizerMapper 
           extends Mapper<Object, Text, Text, IntWritable>{
        
        private final static IntWritable one = new IntWritable(1);
        private Text word = new Text();
          
        public void map(Object key, Text value, Context context
                        ) throws IOException, InterruptedException {
          StringTokenizer itr = new StringTokenizer(value.toString());
          while (itr.hasMoreTokens()) {
            word.set(itr.nextToken());
            context.write(word, one);
          }
        }
      }
      
      public static class IntSumReducer 
           extends Reducer<Text,IntWritable,Text,IntWritable> {
        private IntWritable result = new IntWritable();    public void reduce(Text key, Iterable<IntWritable> values, 
                           Context context
                           ) throws IOException, InterruptedException {
          int sum = 0;
          for (IntWritable val : values) {
            sum += val.get();
          }
          result.set(sum);
          context.write(key, result);
        }
      }  public static void main(String[] args) throws Exception {
        Configuration conf = new Configuration();
        String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
        if (otherArgs.length != 2) {
          System.err.println("Usage: wordcount <in> <out>");
          System.exit(2);
        }
        Job job = new Job(conf, "word count");
        job.setJarByClass(WordCount.class);
        job.setMapperClass(TokenizerMapper.class);
        job.setCombinerClass(IntSumReducer.class);
        job.setReducerClass(IntSumReducer.class);
       
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(IntWritable.class);
        
        FileInputFormat.addInputPath(job, new Path(otherArgs[0]));
        FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));
        System.exit(job.waitForCompletion(true) ? 0 : 1);
      }
    }
      

  2.   

    jsp不好使?那是java环境的问题啊,/etc/profile配置是不是出问题了。还有hadop-env.sh也得设置javahome。
      

  3.   

    jps命令是在jdk的bin目录中
      

  4.   

    jps是jdk里面用来查看java进程的命令。请将jar包重新打下,试试。