问题描述:
测试yarn 的时候,启动wordcount 测试用例失败,出现以下提示
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}<alue>
</property>
<property>
<name>mapreduce.map.env</name>
<value>HADOOP_MAPRED_HOME=${full path of your hadoop distribution directory}<alue>
</property>
<property>
<name>mapreduce.reduce.env</name>
<value>HADOOP_MAPRED_HOME=${full path of your hadoop distribution directory}<alue>
</property>
For more detailed output, check the application tracking page: http://hadoop103:8088/cluster/app/application_1638539388325_0001 Then click on links to logs of each attempt.
. Failing the application.
原因分析
从投出来的信息就可以看到关键HADOOP_MAPRED_HOME ,后边都是一个赋值的语句,说明这个对应的值不存在,那么需要你配置的这个值,然后才找到相应的类路径
方法一
这里简便起见直接使用环境变量,yarn 中使用环境变量需要进行继承环境变量,在yarn-site.xml 添加如下,其中HADOOP_MAPRED_HOME 就是我们需要的,其余的按需求放就行了,我这里是放了一些常用的
<property>
<name>yarn.nodemanager.env-whitelist</name>,
<value>JAVA_HOME,HADOOP_HOME,HADOOP_COMMON_HOME, HADOOP_ HDFS_HOME, HADOOP_ CONF_DIR, CLASSPATH_PREPEND_DISTCACHE, HADOOP_YARN_HOME, HADOOP_MAPRED_HOME
</value>
</property>
在环境变量中添加HADOOP_MAPRED_HOME 并导出,其他的是常用的,随便配,主要是HADOOP_MAPRED_HOME ,最后记得重启系统或者重启连接服务,使环境变量生效
JAVA_HOME=/opt/module/java-1.8.0-openjdk-1.8.0.312.b07-1.el7_9.x86_64
HADOOP_MAPRED_HOME=/opt/module/hadoop-3.1.3
HADOOP_HOME=/opt/module/hadoop-3.1.3
PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
export PATH JAVA_HOME HADOOP_HOME HADOOP_MAPRED_HOME
要是开启了多个服务器相关的yarn 服务,记得每个服务器都配一下
方法二
在yarn-site.xml 和mapred-site.xml 都添加以下内容
<property>
<name>yarn.application.classpath</name>
<value>
${HADOOP_HOME}/etc/*,
${HADOOP_HOME}/etc/hadoop/*,
${HADOOP_HOME}/lib/*,
${HADOOP_HOME}/share/hadoop/common/*,
${HADOOP_HOME}/share/hadoop/common/lib/*,
${HADOOP_HOME}/share/hadoop/mapreduce/*,
${HADOOP_HOME}/share/hadoop/mapreduce/lib-examples/*,
${HADOOP_HOME}/share/hadoop/hdfs/*,
${HADOOP_HOME}/share/hadoop/hdfs/lib/*,
${HADOOP_HOME}/share/hadoop/yarn/*,
${HADOOP_HOME}/share/hadoop/yarn/lib/*,
</value>
</property>
因为使用到了${HADOOP_HOME} ,所以需要继承环境变量,在yarn-site.xml 添加如下,其中HADOOP_HOME 就是我们需要的,其余的按需求放就行了,我这里是放了一些常用的
<property>
<name>yarn.nodemanager.env-whitelist</name>,
<value>JAVA_HOME,HADOOP_HOME,HADOOP_COMMON_HOME, HADOOP_ HDFS_HOME, HADOOP_ CONF_DIR, CLASSPATH_PREPEND_DISTCACHE, HADOOP_YARN_HOME, HADOOP_MAPRED_HOME
</value>
</property>
要是开启了多个服务器相关的yarn 服务,记得每个服务器都配一下
|