1. 修改配置
进入 ${HADOOP_HOME}/etc/hadoop/ 目录下,修改以下配置:
- mapred-site.xml
[root@tcloud ~]# vim /usr/local/hadoop-3.1.3/etc/hadoop/mapred-site.xml
<configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> <!-- 历史服务器地址 --> <property> <name>mapreduce.jobhistory.address</name> <value>tcloud:10020</value> </property> <property> <name>mapreduce.jobhistory.webapp.address</name> <value>tcloud:19888</value> </property> </configuration>
yarn-site.xml
[root@tcloud ~]# vim /usr/local/hadoop-3.1.3/etc/hadoop/yarn-site.xml
<configuration> <property> <!--配置NodeManager上运行的附属服务。需要配置成mapreduce_shuffle后才可以在Yarn上运行MapReduce程序--> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> <!-- resourcemanager配置 单机版可以在同一台服务器上可以不配置 --> <property> <name>yarn.resourcemanager.hostname</name> <value>tcloud</value> </property> <!-- 白名单 --> <property> <name>yarn.nodemanager.env-whitelist</name> <value>JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_MAPRED_HOME</value> </property> <!-- 以下配置要根据服务器情况进行配置 我的云服务器只有2G的内存--> <property> <name>yarn.scheduler.minimum-allocation-mb</name> <value>128</value> </property> <property> <name>yarn.scheduler.maximum-allocation-mb</name> <value>256</value> </property> <property> <name>yarn.nodemanager.resource.memory-mb</name> <value>256</value> </property> <property> <name>yarn.nodemanager.pmem-check-enabled</name> <value>false</value> </property> <property> <name>yarn.nodemanager.vmem-check-enabled</name> <value>false</value> </property> <!-- 开启日志聚集功能 --> <property> <name>yarn.log-aggregation-enable</name> <value>true</value> </property> <!-- 设置日志聚集服务器地址 --> <property> <name>yarn.log.server.url</name> <value>http://tcloud:19888/jobhistory/logs</value> </property> <!-- 设置日志保留时间为7天 --> <property> <name>yarn.log-aggregation.retain-seconds</name> <value>604800</value> </property> </configuration>
2.修改启动和停止shell脚本
[root@tcloud hadoop]# vim /usr/local/hadoop-3.1.3/sbin/start-yarn.sh [root@tcloud hadoop]# vim /usr/local/hadoop-3.1.3/sbin/stop-yarn.sh
start-yarn.sh,stop-yarn.sh 这两个文件顶部添加以下参数:
YARN_RESOURCEMANAGER_USER=root HDFS_DATANODE_SECURE_USER=yarn YARN_NODEMANAGER_USER=root
3. 启动服务
进入 ${HADOOP_HOME}/sbin/ 目录下,启动 YARN:
[root@tcloud sbin]# ./start-yarn.sh
4. 验证是否启动成功
方式一:执行 jps 命令查看 NodeManager 和 ResourceManager 服务是否已经启动:
[root@tcloud sbin]# jps 1701 NameNode 1848 DataNode 7512 Jps 7198 NodeManager 7055 ResourceManager 2095 SecondaryNameNode
方式二:查看 Web UI 界面,端口号为 ==8088==