问题描述:
输入两个文件:
第一个文件内容: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
输入两个文件:
第一个文件内容: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
解决方案 »
- 各位高手请进:swift API的封装或如何在java代码中实现swift api 接口的调用?
- Swift应用的案例
- 从苹果iPhone6上市,解读云存储产业生态圈
- openstack计算节点启动失败。分开安装,全放一台都不能启动
- 6.cn和12306.cn是共用同一个网络地址
- 我搭建的hadoop2.4.0完全分布集群,起了两个manenode,zkfc没有启动,请问怎么解决?
- sparkStreaming 找出一段时间内第一次和最后一次出现的字母
- Spark编程实现问题,求指导!
- 请教一个网络问题
- 服务器高负荷与寿命、故障率之间有什么关系?
- 新手求助!500多台设备配AAA认证
- 如何学习云计算
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);
}
}