1,在工程src目录下加入mapred-site.xml和yarn-site.xml
2,在main方法中添加一个conf的配置参数 conf.set("mapreduce.jar","wc.jar")
注意:wc.jar
--自定义jar包名称
3,执行maven install把工程打成jar包
4,在target目录下找到jar包,右键,build path->add to build path
执行日志:
2016-10-23 17:12:31,590 WARN [org.apache.hadoop.util.NativeCodeLoader] - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2016-10-23 17:12:33,117 INFO [org.apache.hadoop.yarn.client.RMProxy] - Connecting to ResourceManager at hadoop/192.168.1.105:8032
2016-10-23 17:12:33,832 WARN [org.apache.hadoop.mapreduce.JobResourceUploader] - Hadoop command-line option parsing not performed. Implement the Tool interface and execute your application with ToolRunner to remedy this.
2016-10-23 17:12:33,995 INFO [org.apache.hadoop.mapreduce.lib.input.FileInputFormat] - Total input paths to process : 4
2016-10-23 17:12:34,184 INFO [org.apache.hadoop.mapreduce.JobSubmitter] - number of splits:4
2016-10-23 17:12:34,451 INFO [org.apache.hadoop.mapreduce.JobSubmitter] - Submitting tokens for job: job_1477180948415_0004
2016-10-23 17:12:34,761 INFO [org.apache.hadoop.yarn.client.api.impl.YarnClientImpl] - Submitted application application_1477180948415_0004
2016-10-23 17:12:34,819 INFO [org.apache.hadoop.mapreduce.Job] - The url to track the job: http://hadoop:8088/proxy/application_1477180948415_0004/
2016-10-23 17:12:34,820 INFO [org.apache.hadoop.mapreduce.Job] - Running job: job_1477180948415_0004
2016-10-23 17:12:41,971 INFO [org.apache.hadoop.mapreduce.Job] - Job job_1477180948415_0004 running in uber mode : false
2016-10-23 17:12:41,975 INFO [org.apache.hadoop.mapreduce.Job] - map 0% reduce 0%
2016-10-23 17:12:53,128 INFO [org.apache.hadoop.mapreduce.Job] - map 25% reduce 0%
2016-10-23 17:12:54,138 INFO [org.apache.hadoop.mapreduce.Job] - map 50% reduce 0%
2016-10-23 17:12:55,150 INFO [org.apache.hadoop.mapreduce.Job] - map 100% reduce 0%
2016-10-23 17:13:01,211 INFO [org.apache.hadoop.mapreduce.Job] - map 100% reduce 100%
2016-10-23 17:13:01,235 INFO [org.apache.hadoop.mapreduce.Job] - Job job_1477180948415_0004 completed successfully
2016-10-23 17:13:01,376 INFO [org.apache.hadoop.mapreduce.Job] - Counters: 50
File System Counters
FILE: Number of bytes read=1611
FILE: Number of bytes written=531033
FILE: Number of read operations=0
FILE: Number of large read operations=0
FILE: Number of write operations=0
HDFS: Number of bytes read=52
HDFS: Number of bytes written=19
HDFS: Number of read operations=11
HDFS: Number of large read operations=0
HDFS: Number of write operations=2
Job Counters
Launched map tasks=4
Launched reduce tasks=1
Other local map tasks=2
Data-local map tasks=2
Total time spent by all maps in occupied slots (ms)=39968
Total time spent by all reduces in occupied slots (ms)=4445
Total time spent by all map tasks (ms)=39968
Total time spent by all reduce tasks (ms)=4445
Total vcore-seconds taken by all map tasks=39968
Total vcore-seconds taken by all reduce tasks=4445
Total megabyte-seconds taken by all map tasks=40927232
Total megabyte-seconds taken by all reduce tasks=4551680
Map-Reduce Framework
Map input records=13
Map output records=13
Map output bytes=78
Map output materialized bytes=73
Input split bytes=370
Combine input records=13
Combine output records=6
Reduce input groups=3
Reduce shuffle bytes=73
Reduce input records=6
Reduce output records=3
Spilled Records=12
Shuffled Maps =4
Failed Shuffles=0
Merged Map outputs=4
GC time elapsed (ms)=425
CPU time spent (ms)=4660
Physical memory (bytes) snapshot=1191030784
Virtual memory (bytes) snapshot=4376879104
Total committed heap usage (bytes)=901251072
Shuffle Errors
BAD_ID=0
CONNECTION=0
IO_ERROR=0
WRONG_LENGTH=0
WRONG_MAP=0
WRONG_REDUCE=0
File Input Format Counters
Bytes Read=52
File Output Format Counters
Bytes Written=19