MapReduce配置 & YARN集群部署

1:编辑mapred-env.sh;添加如下配置

#设置jdk路径
export JAVA_HOME=/opt/module/jdk
#设置JobHistoryServer进程内存为1G
export HADOOP_JOB_HISTORYSERVER_HEAPSIZE=1000
#设置日志级别为INFO
export HADOOP_MAPRED_ROOT_LOGGER=INFO,RFA

2:编辑mapred-site.xml;添加如下配置

<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
<description>MapReduce的运行框架设置为YARN</description>
</property>

<property>
<name>mapreduce.jobhistory.address</name>
<value>master:10020</value>
<description>历史服务器通讯端口为master:10020</description>
</property>

<property>
<name>mapreduce.jobhistory.webapp.address</name>
<value>master:19888</value>
<description>历史服务器web的端口为master:19888</description>
</property>

<property>
<name>mapreduce.jobhistory.intermediate-done-dir</name>
<value>/data/mr-history/tmp</value>
<description>历史信息在HDFS的记录临时路径</description>
</property>

<property>
<name>mapreduce.jobhistory.done-dir</name>
<value>/data/mr-history/done</value>
<description>历史信息在HDFS的记录路径</description>
</property>

<property>
<name>yarn.app.mapreduce.am.env</name>
<value>HADOOP_MAPRED_HOME=$HADOOP_HOME</value>
<description>MAPREDUCE HOME 设置为HADOOP_HOME</description>
</property>

<property>
<name>mapreduce.map.env</name>
<value>HADOOP_MAPRED_HOME=$HADOOP_HOME</value>
<description>MAPREDUCE HOME 设置为HADOOP_HOME</description>
</property>

<property>
<name>mapreduce.reduce.env</name>
<value>HADOOP_MAPRED_HOME=$HADOOP_HOME</value>
<description>MAPREDUCE HOME 设置为HADOOP_HOME</description>
</property>

3:编辑yarn-env.sh;添加如下配置

#设置jdk路径的环境变量
export JAVA_HOME=/opt/module/jdk
#设置hadoop_home的环境变量
export HADOOP_HOME=/opt/module/hadoop
#设置配置文件路径的环境变量
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
#设置日志文件路径的环境变量
export HADOOP_LOG_DIR=$HADOOP_HOME/logs

4:yarn-site.xml;添加如下配置:

<property>
<name>yarn.resourcemanager.hostname</name>
<value>master</value>
<description>Resourcemanager设置在master节点</description>
</property>

<property>
<name>yarn.nodemanager.local-dirs</name>
<value>/data/nm-local</value>
<description>nodemanager中间数据本地存储路径</description>
</property>

<property>
<name>yarn.nodemanager.log-dirs</name>
<value>/data/nm-log</value>
<description>NodeManager 数据日志本地存储路径</description>
</property>

<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
<description>为mapreduce程序开启shuffle服务</description>
</property>

<property>
<name>yarn.log.server.url</name>
<value>http://master:19888/jobhistory/logs</value>
<description>历史服务器url</description>
</property>

<property>
<name>yarn.web-proxy.address</name>
<value>master:8089</value>
<description>代理服务器主机和端口</description>
</property>

<property>
<name>yarn.log-aggregation-enable</name>
<value>true</value>
<description>开启日志聚合</description>
</property>

<property>
<name>yarn.nodemanager.remote-app-log-dir</name>
<value>/tmp/logs</value>
<description>程序日志HDFS的存储路径</description>
</property>

<property>
<name>yarn.resourcemanager.Scheduler.class</name>
<value>org.apache.hadoop.yarn.server.resourcemanager.Scheduler.fair.FairScheudler</value>
<description>选择公平调度器</description>
</property>

分发

scp mapred-env.sh mapred-site.xml yarn-env.sh yarn-site.xml slave1:`pwd`/
scp mapred-env.sh mapred-site.xml yarn-env.sh yarn-site.xml slave2:`pwd`/

分发完成就可以启动YARN的相关进程了

start-all.sh

在当前机器也可以单独启动或停止进程

$HADOOP_HOME/bin/yarn --daemon start|stop resourcemanager|nodemanager|proxyserver

历史服务器启动和停止

$HADOOP_HOME/bin/mapred --daemon start|stop historyserver