提交MR作业到yarn上运行:wc
官方代码:
/app/hadoop-2.6.0-cdh5.7.0/share/hadoop/mapreduce
- 启动jar包1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12cd /home/hadoop/app/hadoop-2.6.0-cdh5.7.0/bin 
 ./hadoop jar /home/hadoop/app/hadoop-2.6.0-cdh5.7.0/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.0-cdh5.7.0.jar
 直接启动启动不起来,提示我们需要输入参数wordcount
 **************
 wordcount: A map/reduce program that counts the words in the input files.
 wordmean: A map/reduce program that counts the average length of the words in the input files.
 wordmedian: A map/reduce program that counts the median length of the words in the input files.
 wordstandarddeviation: A map/reduce program that counts the standard deviation of the length of the words in the input files.
 ***************
- 创建一个hello.txt文件并上传 - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15- hello.txt 
 hello world welcome
 hello welcome
 上传hello.txt文件到hdfs中
 - hadoop fs -put hello.txt -p /input/wc/
 查看文件是否上传成功
 - hadoop fs -text /input/wc/hello.txt
 *************
 18/12/06 12:14:20 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
 hello world welcome
 hello welcome
 *************
- 执行hadoop wc任务 - 1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12- ./hadoop jar /home/hadoop/app/hadoop-2.6.0-cdh5.7.0/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.0-cdh5.7.0.jar wordcount /input/wc/hello.txt /output/wc/ 
 等待任务执行结果
 结束之后hadoop fs -ls /output/wc/
 可以看到我们的输出结果已经在hdfs中产生了输出结果
 ***********
 18/12/06 12:17:16 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
 Found 2 items
 -rw-r--r-- 1 root supergroup 0 2018-12-06 12:16 /output/wc/_SUCCESS
 -rw-r--r-- 1 root supergroup 26 2018-12-06 12:16 /output/wc/part-r-00000
 ***********
- 查看一下输出的值 - 1 
 2
 3
 4
 5
 6
 7- hadoop fs -cat /output/wc/part-r-00000 
 ******************
 18/12/08 18:34:11 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
 hello 2
 welcome 2
 world 1
 ******************
结合日志回顾任务执行过程
| 1 | 18/12/08 18:30:16 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable | 
- 任务执行的过程,我们在yarn上也是可以实时查看到情况的 
