配置集群
- 配置yarn-env.sh
配置一下JAVA_HOME
export JAVA_HOME=/opt/module/jdk1.8.0_144
- 配置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>hadoop101</value>
</property>
- 配置:mapred-env.sh
配置一下JAVA_HOME
export JAVA_HOME=/opt/module/jdk1.8.0_144
- 配置: (对mapred-site.xml.template重新命名为) mapred-site.xml
[liujh@hadoop101 hadoop]$ mv mapred-site.xml.template mapred-site.xml
[liujh@hadoop101 hadoop]$ vi mapred-site.xml
<!-- 指定MR运行在YARN上 -->
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
启动集群
- 启动前必须保证NameNode和DataNode已经启动
- 启动ResourceManager
[liujh@hadoop101 hadoop-2.7.2]$ sbin/yarn-daemon.sh start resourcemanager
- 启动NodeManager
[liujh@hadoop101 hadoop-2.7.2]$ sbin/yarn-daemon.sh start nodemanager
集群操作
- YARN的浏览器页面查看 http://hadoop101:8088/cluster
- 删除文件系统上的output文件
[liujh@hadoop101 hadoop-2.7.2]$ bin/hdfs dfs -rm -R /user/liujh/output
- 执行MapReduce程序
[liujh@hadoop101 hadoop-2.7.2]$ bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar wordcount /user/liujh/input /user/liujh/output
- 查看运行结果
[liujh@hadoop101 hadoop-2.7.2]$ bin/hdfs dfs -cat /user/liujh/output/*
简书:https://www.jianshu.com/u/0278602aea1d
CSDN:https://blog.csdn.net/u012387141
特别感谢:尚硅谷教育