Hadoop YARN上运行MapReduce程序

时间:2024-01-15 08:23:50

(1)配置集群

(a)配置hadoop-2.7.2/etc/hadoop/yarn-env.sh

配置一下JAVA_HOME

export JAVA_HOME=/home/hadoop/bigdatasoftware/jdk1.8.0_161

(b)配置yarn-site.xml

<!-- reducer获取数据的方式 -->

<property>

<name>yarn.nodemanager.aux-services</name>

<value>mapreduce_shuffle</value>

</property>

<!-- 指定YARN的ResourceManager的地址 -->

<property>

<name>yarn.resourcemanager.hostname</name>

<value>hadoop-002</value>

</property>

(c)配置:mapred-env.sh

配置一下JAVA_HOME

export JAVA_HOME=/home/hadoop/bigdatasoftware/jdk1.8.0_161

<!-- 指定mr运行在yarn上 -->

<property>

<name>mapreduce.framework.name</name>

<value>yarn</value>

</property>

(d)配置: (对mapred-site.xml.template重新命名为) mapred-site.xml

(2)启动集群

(a)启动resourcemanager

sbin/yarn-daemon.sh start resourcemanager

(b)启动nodemanager

sbin/yarn-daemon.sh start nodemanager

(3)集群操作

(a)yarn的浏览器页面查看

http://hadoop-001:8088/cluster

Hadoop YARN上运行MapReduce程序

(b)删除文件系统上的output文件

bin/hdfs dfs -rm -R /home/hadoop/mapreduce/wordcount/output

(c)执行mapreduce程序

bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar wordcount /home/hadoop/mapreduce/wordcount/input  /user/hadoop/mapreduce/wordcount/output

(d)查看运行结果

bin/hdfs dfs -cat /home/hadoop/mapreduce/wordcount/output/*

Hadoop YARN上运行MapReduce程序