在eclipse上运行mapreduce小程序,出现警告提示:No job jar file set.到底是哪里的问题呢?请大神赐教!
错误提示:
17/04/17 13:22:29 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
17/04/17 13:22:30 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032
17/04/17 13:22:31 WARN mapreduce.JobResourceUploader: No job jar file set. User classes may not be found. See Job or Job#setJar(String).
17/04/17 13:22:31 INFO input.FileInputFormat: Total input paths to process : 3
17/04/17 13:22:32 INFO mapreduce.JobSubmitter: number of splits:3
17/04/17 13:22:32 INFO Configuration.deprecation: mapred.job.tracker is deprecated. Instead, use mapreduce.jobtracker.address
17/04/17 13:22:33 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1492406451078_0001
17/04/17 13:22:33 INFO mapred.YARNRunner: Job jar is not present. Not adding any jar to the list of resources.
17/04/17 13:22:34 INFO impl.YarnClientImpl: Submitted application application_1492406451078_0001
17/04/17 13:22:34 INFO mapreduce.Job: The url to track the job: http://youhuidi-Lenovo-G470:8088/proxy/application_1492406451078_0001/
17/04/17 13:22:34 INFO mapreduce.Job: Running job: job_1492406451078_0001
17/04/17 13:22:45 INFO mapreduce.Job: Job job_1492406451078_0001 running in uber mode : false
17/04/17 13:22:45 INFO mapreduce.Job: map 0% reduce 0%
17/04/17 13:28:50 INFO ipc.Client: Retrying connect to server: youhuidi-Lenovo-G470/127.0.1.1:46461. Already tried 0 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=3, sleepTime=1000 MILLISECONDS)
17/04/17 13:28:51 INFO ipc.Client: Retrying connect to server: youhuidi-Lenovo-G470/127.0.1.1:46461. Already tried 1 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=3, sleepTime=1000 MILLISECONDS)
17/04/17 13:28:52 INFO ipc.Client: Retrying connect to server: youhuidi-Lenovo-G470/127.0.1.1:46461. Already tried 2 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=3, sleepTime=1000 MILLISECONDS)
17/04/17 13:35:13 INFO ipc.Client: Retrying connect to server: youhuidi-Lenovo-G470/127.0.1.1:35093. Already tried 0 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=3, sleepTime=1000 MILLISECONDS)
17/04/17 13:35:14 INFO ipc.Client: Retrying connect to server: youhuidi-Lenovo-G470/127.0.1.1:35093. Already tried 1 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=3, sleepTime=1000 MILLISECONDS)
17/04/17 13:35:15 INFO ipc.Client: Retrying connect to server: youhuidi-Lenovo-G470/127.0.1.1:35093. Already tried 2 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=3, sleepTime=1000 MILLISECONDS)
17/04/17 13:35:15 INFO mapreduce.Job: Job job_1492406451078_0001 failed with state FAILED due to: Application application_1492406451078_0001 failed 2 times due to AM Container for appattempt_1492406451078_0001_000002 exited with exitCode: 0
For more detailed output, check application tracking page:http://youhuidi-Lenovo-G470:8088/cluster/app/application_1492406451078_0001Then, click on links to logs of each attempt.
Diagnostics: Failing this attempt. Failing the application.
17/04/17 13:35:15 INFO mapreduce.Job: Counters: 0
mapreduce小程序代码:
package org.apache.hadoop.examples;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
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 {
//map将输入中的value复制到输出数据的key上,并直接输出
public static class Map extends Mapper<Object,Text,Text,Text>{
private static Text line=new Text();//每行数据
//实现map函数
public void map(Object key,Text value,Context context)
throws IOException,InterruptedException{
line=value;
context.write(line, new Text(""));
}
}
//reduce将输入中的key复制到输出数据的key上,并直接输出
public static class Reduce extends Reducer<Text,Text,Text,Text>{
//实现reduce函数
public void reduce(Text key,Iterable<Text> values,Context context)
throws IOException,InterruptedException{
context.write(key, new Text(""));
}
}
public static void main(String[] args) throws Exception{
Configuration conf = new Configuration();
//这句话很关键
conf.set("mapred.job.tracker", "192.168.1.2:8088");
String[] ioArgs=new String[]{"dedup_in","dedup_out"};
String[] otherArgs = new GenericOptionsParser(conf, ioArgs).getRemainingArgs();
if (otherArgs.length != 2) {
System.err.println("Usage: Data Deduplication <in> <out>");
System.exit(2);
}
@SuppressWarnings("deprecation")
Job job = new Job(conf, "Data Deduplication");
job.setJarByClass(WordCount.class);
//设置Map、Combine和Reduce处理类
job.setMapperClass(Map.class);
job.setCombinerClass(Reduce.class);
job.setReducerClass(Reduce.class);
//设置输出类型
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
//设置输入和输出目录
FileInputFormat.addInputPath(job, new Path(otherArgs[0]));
FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));
System.exit(job.waitForCompletion(true) ? 0 : 1);
}
}
17/04/17 13:22:29 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
17/04/17 13:22:30 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032
17/04/17 13:22:31 WARN mapreduce.JobResourceUploader: No job jar file set. User classes may not be found. See Job or Job#setJar(String).
17/04/17 13:22:31 INFO input.FileInputFormat: Total input paths to process : 3
17/04/17 13:22:32 INFO mapreduce.JobSubmitter: number of splits:3
17/04/17 13:22:32 INFO Configuration.deprecation: mapred.job.tracker is deprecated. Instead, use mapreduce.jobtracker.address
17/04/17 13:22:33 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1492406451078_0001
17/04/17 13:22:33 INFO mapred.YARNRunner: Job jar is not present. Not adding any jar to the list of resources.
17/04/17 13:22:34 INFO impl.YarnClientImpl: Submitted application application_1492406451078_0001
17/04/17 13:22:34 INFO mapreduce.Job: The url to track the job: http://youhuidi-Lenovo-G470:8088/proxy/application_1492406451078_0001/
17/04/17 13:22:34 INFO mapreduce.Job: Running job: job_1492406451078_0001
17/04/17 13:22:45 INFO mapreduce.Job: Job job_1492406451078_0001 running in uber mode : false
17/04/17 13:22:45 INFO mapreduce.Job: map 0% reduce 0%
17/04/17 13:28:50 INFO ipc.Client: Retrying connect to server: youhuidi-Lenovo-G470/127.0.1.1:46461. Already tried 0 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=3, sleepTime=1000 MILLISECONDS)
17/04/17 13:28:51 INFO ipc.Client: Retrying connect to server: youhuidi-Lenovo-G470/127.0.1.1:46461. Already tried 1 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=3, sleepTime=1000 MILLISECONDS)
17/04/17 13:28:52 INFO ipc.Client: Retrying connect to server: youhuidi-Lenovo-G470/127.0.1.1:46461. Already tried 2 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=3, sleepTime=1000 MILLISECONDS)
17/04/17 13:35:13 INFO ipc.Client: Retrying connect to server: youhuidi-Lenovo-G470/127.0.1.1:35093. Already tried 0 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=3, sleepTime=1000 MILLISECONDS)
17/04/17 13:35:14 INFO ipc.Client: Retrying connect to server: youhuidi-Lenovo-G470/127.0.1.1:35093. Already tried 1 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=3, sleepTime=1000 MILLISECONDS)
17/04/17 13:35:15 INFO ipc.Client: Retrying connect to server: youhuidi-Lenovo-G470/127.0.1.1:35093. Already tried 2 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=3, sleepTime=1000 MILLISECONDS)
17/04/17 13:35:15 INFO mapreduce.Job: Job job_1492406451078_0001 failed with state FAILED due to: Application application_1492406451078_0001 failed 2 times due to AM Container for appattempt_1492406451078_0001_000002 exited with exitCode: 0
For more detailed output, check application tracking page:http://youhuidi-Lenovo-G470:8088/cluster/app/application_1492406451078_0001Then, click on links to logs of each attempt.
Diagnostics: Failing this attempt. Failing the application.
17/04/17 13:35:15 INFO mapreduce.Job: Counters: 0
mapreduce小程序代码:
package org.apache.hadoop.examples;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
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 {
//map将输入中的value复制到输出数据的key上,并直接输出
public static class Map extends Mapper<Object,Text,Text,Text>{
private static Text line=new Text();//每行数据
//实现map函数
public void map(Object key,Text value,Context context)
throws IOException,InterruptedException{
line=value;
context.write(line, new Text(""));
}
}
//reduce将输入中的key复制到输出数据的key上,并直接输出
public static class Reduce extends Reducer<Text,Text,Text,Text>{
//实现reduce函数
public void reduce(Text key,Iterable<Text> values,Context context)
throws IOException,InterruptedException{
context.write(key, new Text(""));
}
}
public static void main(String[] args) throws Exception{
Configuration conf = new Configuration();
//这句话很关键
conf.set("mapred.job.tracker", "192.168.1.2:8088");
String[] ioArgs=new String[]{"dedup_in","dedup_out"};
String[] otherArgs = new GenericOptionsParser(conf, ioArgs).getRemainingArgs();
if (otherArgs.length != 2) {
System.err.println("Usage: Data Deduplication <in> <out>");
System.exit(2);
}
@SuppressWarnings("deprecation")
Job job = new Job(conf, "Data Deduplication");
job.setJarByClass(WordCount.class);
//设置Map、Combine和Reduce处理类
job.setMapperClass(Map.class);
job.setCombinerClass(Reduce.class);
job.setReducerClass(Reduce.class);
//设置输出类型
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
//设置输入和输出目录
FileInputFormat.addInputPath(job, new Path(otherArgs[0]));
FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));
System.exit(job.waitForCompletion(true) ? 0 : 1);
}
}
...全文
相关推荐
hadoop eclipse mapreduce下开发所有需要用到的JAR包
在Eclipse中,可以通过创建一个Java项目,然后将这些JAR包添加到项目的构建路径中,以便编译和运行MapReduce作业。
【信息科学与工程学】计算机科学与自动化 第二百零一十一 软件开发模型01
编号类型模型领域模型中的知识点/因素/参数关联知识和法律法规1传统顺序模型瀑布模型 (Waterfall)通用软件开发、硬件紧密耦合系统、政府/军工项目、需求稳定的传统信息系统严格线性阶段:可行性研究→需求分析(SRS,含功能/非功能/接口/约束,使用IEEE 830模板)→系统设计(概要设计HLD:架构、模块划分、数据库ER图;详细设计LLD:伪代码、类图、接口定义)→实现(编码规范、代码审查、静态分析工具SonarQube)→测试(单元测试JUnit、集成测试、系统测试、验收测试UAT,测试计划提前编写
使用命令行编译打包运行自己的MapReduce程序 Hadoop2.6.0
在Eclipse中,可以轻松地管理项目依赖、编译代码以及打包成JAR文件。此外,Eclipse还提供了运行MapReduce程序的功能,使得整个过程更加简便。
Hadoop下Eclipse用Java编程实现WordCount
#### 三、在Eclipse中创建项目1. **创建Java项目**: - 打开Eclipse,选择“File” -> “New” -> “Java Project”。
hadoop-eclipse-plugin-1.0.0(5个版本)
**日志查看**:在Eclipse内部查看MapReduce任务的运行日志,便于调试和问题定位。6.


