Error: Could not find or load main class org.apache.hadoop.mapreduce.v2.app.MRAppMaster

Posted ZSYL

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Error: Could not find or load main class org.apache.hadoop.mapreduce.v2.app.MRAppMaster相关的知识,希望对你有一定的参考价值。

Hadoop3.2.1在虚拟机环境下运行MapReduce 下wordCount出现以下报错解决

问题描述

Hadoop3.2.1在虚拟机环境下运行MapReduce下wordCount.

执行以下命令:

hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-3.1.3.jar wordcount /wcinput /wcoutput 

报错:

[2021-09-04 16:23:11.541]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:
<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>

For more detailed output, check the application tracking page: http://hadoop103:8088/cluster/app/application_1630740583049_0005 Then click on links to logs of each attempt.
. Failing the application.
2021-09-04 16:23:12,392 INFO mapreduce.Job: Counters: 0

解决办法

找到hadoop安装目录下/usr/local/hadoop-3.2.1/etc/hadoop/mapred-site.xml,修改配置文件:

<configuration>
  <!-- 指定 MapReduce 程序运行在 Yarn 上 -->
  <property>
   <name>mapreduce.framework.name</name>
   <value>yarn</value>
  </property>
  
 <property>
   <name>yarn.app.mapreduce.am.env</name>
   <value>HADOOP_MAPRED_HOME=/opt/module/hadoop-3.1.3</value>
 </property>
 <property>
   <name>mapreduce.map.env</name>
   <value>HADOOP_MAPRED_HOME=/opt/module/hadoop-3.1.3</value>
 </property>
 <property>
   <name>mapreduce.reduce.env</name>
   <value>HADOOP_MAPRED_HOME=/opt/module/hadoop-3.1.3</value>
  </property>
</configuration>

最后成功运行!


参考Link

以上是关于Error: Could not find or load main class org.apache.hadoop.mapreduce.v2.app.MRAppMaster的主要内容,如果未能解决你的问题,请参考以下文章

CentOS下运行Java文件Error: Could not find or load main class

Error: Could not find or load main class org.apache.hadoop.fs.FsShell

Error: Could not find or load main class org.apache.hadoop.fs.FsShell

cmd运行Java中文乱码,无法加载主类Error: Could not find or load main class

解决Zookeeper出现Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerM

Error: Could not find or load main class org.apache.hadoop.mapreduce.v2.app.MRAppMaster