场景
在Hadoop3.13
的YARN上运行MapReduce
报错信息
终端界面提示 |
---|
FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask |
再查YARN历史 |
---|
Error: Could not find or load main class org.apache.hadoop.mapreduce.v2.app.MRAppMaster |
Please check whether your etc/hadoop/mapred-site.xml contains the below configuration:
<property>
<name>yarn.app.mapreduce.am.env</name>
<value>HADOOP_MAPRED_HOME=${full path of your hadoop distribution directory}</value>
</property>
<property>
<name>mapreduce.map.env</name>
<value>HADOOP_MAPRED_HOME=${full path of your hadoop distribution directory}</value>
</property>
<property>
<name>mapreduce.reduce.env</name>
<value>HADOOP_MAPRED_HOME=${full path of your hadoop distribution directory}</value>
</property>
解决方案
vi $HADOOP_HOME/etc/hadoop/yarn-site.xml
<!--
环境变量通过从NodeManagers的容器继承的环境属性,
对于MapReduce应用程序,
除了 默认值 hadoop op_mapred_home 应被加入 外,
还有如下属性值:
-->
<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>
修改值 和 默认值 的区别
- 修改值:
JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,
HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,
HADOOP_MAPRED_HOME - 默认值:
JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,
HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,
HADOOP_HOME,PATH,LANG,TZ
参数详解
MapReducer
执行时,会在NodeManager
上创建Container
,在Container
上执行Task
(JAVA程序),该程序需要环境变量(如:JDK、HADOOP_MAPRED_HOME…)- 该参数就是 设置
Container
的能继承NodeManager
的哪些环境变量