|NO.Z.00031|——————————|BigDataEnd|——|Hadoop&MapReduce.V04|——|Hadoop.v04|WordCount案例之编写本地YARN运行.v02|
一、运行任务
### --- 本地模式
~~~ 直接运行会报错:因为没有设置传参
~~~ 直接Idea中运行驱动类即可:idea运行需要传入参数:
~~~ IDEA.Driver传参:WORDCOUNTDRIVER——>edit configuration
~~~ 在program arguments设置参数
~~~ 运行结束,去到输出结果路径查看结果
~~~ 注意本地idea运行mr任务与集群没有任何关系,没有提交任务到yarn集群,
~~~ 是在本地使用多线程方式模拟的mr的运行。




二、Yarn集群模式
### --- Yarn集群模式
~~~ 把程序打成jar包,改名为wc.jar;上传到Hadoop集群选择合适的Jar包
~~~ IDEA打成Jar包:右侧——>maven——>wordcount——>lifecycle——>clean——>package——>

### --- 准备原始数据文件,上传到HDFS的路径,不能是本地路径,因为跨节点运行无法获取数据!!
[root@linux121 ~]# ls
wc.jar wc.txt
### --- 启动Hadoop集群(Hdfs,Yarn)
~~~ 使用Hadoop 命令提交任务运行
[root@linux121 ~]# hadoop jar wc.jar com.yanqi.mr.wc.WordCountDriver /user/yanqi/input /user/yanqi/output
21/08/15 21:29:28 INFO mapreduce.Job: Job job_1628995889675_0001 completed successfully
三、通过dfs查看是否生成数据

四、Yarn集群任务运行成功展示图

Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
——W.S.Landor
浙公网安备 33010602011771号