hadoop运行踩坑:Error: Could not find or load main class org.apache.hadoop.mapreduce.v2.app.

Posted 亿钱君

tags:

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

错误:
Error: Could not find or load main class org.apache.hadoop.mapreduce.v2.app.
说明:计算wordcount出错,错误提示补充mapred-site.xml配置

解决方法:1
这个在我这里不管用(很多博客都说改这个)
在 mapred-site-xml中插入以下代码

<property>
  <name>yarn.app.mapreduce.am.env</name>
  <value>HADOOP_MAPRED_HOME=$HADOOP_HOME</value>
</property>
<property>
  <name>mapreduce.map.env</name>
  <value>HADOOP_MAPRED_HOME=$HADOOP_HOME</value>
</property>
<property>
  <name>mapreduce.reduce.env</name>
  <value>HADOOP_MAPRED_HOME=$HADOOP_HOME</value>
</property>

解决方法2:(亲测有效)

  • 1:输入命令:hadoop classpath
    举例:
  • 2:复制该返回值,并修改成以下格式
        <property>
           <name>yarn.application.classpath</name>
           <value>
                /opt/module/hadoop-3.1.3/etc/hadoop,
                /opt/module/hadoop-3.1.3/share/hadoop/common/lib/*,
                /opt/module/hadoop-3.1.3/share/hadoop/common/*,
                /opt/module/hadoop-3.1.3/share/hadoop/hdfs,
                /opt/module/hadoop-3.1.3/share/hadoop/hdfs/lib/*,
                /opt/module/hadoop-3.1.3/share/hadoop/hdfs/*,
                /opt/module/hadoop-3.1.3/share/hadoop/mapreduce/lib/*,
                /opt/module/hadoop-3.1.3/share/hadoop/mapreduce/*,
                /opt/module/hadoop-3.1.3/share/hadoop/yarn,
                /opt/module/hadoop-3.1.3/share/hadoop/yarn/lib/*,
                /opt/module/hadoop-3.1.3/share/hadoop/yarn/*,

          </value>
        </property>

  • 3:然后把该代码分别加入到yarn-site.xmlmapred-site.xml里面
    举例yarn-site.xml,mapred-site.xml同

    !!!!记得将这两个修改的文件分发到其他的机器,然后重启yarn,dfs


成功!!!(开心)

HDFS上结果!!!

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

Hadoop遇到的坑运行hadoop自带的例子报错 Error: Could not find or load main class org.apache.hadoop.mapred.YarnCh(代

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

Error: Could not open client transport with JDBC Uri: jdbc:hive2://hadoop102:10000: Failed to open n

hadoop Error: JAVA_HOME is not set and could not be found.

Hadoop启动报Error: JAVA_HOME is not set and could not be found解决办法

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