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

Error:
Error: Could not find or load main class org.apache.hadoop.mapreduce.v2.app.
Description: There is an error calculating wordcount, the error prompts to supplement the mapred-site.xml configuration
Insert picture description here

Solution: 1 :
This is here for meit does not work(Many blogs say to change this)
Insert the following code in 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>

Solution 2: (Pro-test effective)

  • 1: Enter the command:hadoop classpath
    For example:
    Insert picture description here
  • 2:Copy the return value and modify it to the following format
        <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: Then add the code toyarn-site.xmlmapred-site.xmlFor
    example, yarn-site.xml, mapred-site.xml is the same
    Insert picture description here
    ! ! ! ! Remember to distribute these two modified files to other machines , and then restart yarn, dfs
    Insert picture description here
    Insert picture description here

success! ! ! (Happy)
Insert picture description here

Results on HDFS! ! !
Insert picture description here

Guess you like

Origin blog.csdn.net/m0_51755061/article/details/114990461