报错信息:
2022-11-10 09:36:44,789 INFO mapreduce.Job: Job job_1668043088418_0004 failed with state FAILED due to: Application application_1668043088418_0004 failed 2 times due to AM Container for appattempt_1668043088418_0004_000002 exited with exitCode: 1
Failing this attempt.Diagnostics: [2022-11-10 09:36:44.190]Exception from container-launch.
Container id: container_1668043088418_0004_02_000001
Exit code: 1
[2022-11-10 09:36:44.193]Container exited with a non-zero exit code 1. Error file: prelaunch.err.
Last 4096 bytes of prelaunch.err :
Last 4096 bytes of stderr :
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:
…
报错信息提示我们找不到main class 可能是环境变量的问题。
解决方法一:
1、在命令行执行,复制路径信息。
hadoop classpath
2、编辑yarn-site.xml,添加信息:
<configuration>
<property>
<name>yarn.application.classpath</name>
<value>复制的Hadoop classpath信息</value>
</property>
</configuration>
3、在所有的主机节点上进行如上设置,设置完毕后重启Hadoop集群,重新运行刚才的MapReduce程序,成功运行。
解决方法二:
1、编辑yarn-site.xml,添加如下信息(须确保之前的环境配置正确):
<!-- 环境变量的继承 -->
<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>
对于上图中< value >包裹的内容一定要连续,即使分段也只能在逗号后断开。
2、在所有的主机节点进行如上设置,设置完毕后重启Hadoop集群即可。文章来源:https://www.toymoban.com/news/detail-412879.html
说明:
其实,在hadoop提供给我们的yarn-default-xml中,已经有了相关的环境变量配置,只不过hadoop3.1有个bug是他没加上HADOOP-MAPRED-HOME,这个问题在3.2就解决了。文章来源地址https://www.toymoban.com/news/detail-412879.html
<property>
<description>Environment variables that containers may override rather than use NodeManager's default.</description>
<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_HOME,PATH,LANG,TZ</value>
</property>
到了这里,关于Could not find or load main class org.apache.hadoop.mapreduce.v2.app.MRAppMaster的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!