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

问题: 运行mapreduce出现以下报错:

2023-12-04 15:06:00,849 INFO mapreduce.Job:  map 0% reduce 0%
2023-12-04 15:06:00,879 INFO mapreduce.Job: Job job_1701673087217_0001 failed with state FAILED due to: Application application_1701673087217_0001 failed 2 times due to AM Container for appattempt_1701673087217_0001_000002 exited with  exitCode: 1
Failing this attempt.Diagnostics: [2023-12-04 15:06:00.159]Exception from container-launch.
Container id: container_1701673087217_0001_02_000001
Exit code: 1

[2023-12-04 15:06:00.199]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 <HADOOP_HOME>/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>

[2023-12-04 15:06:00.200]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 <HADOOP_HOME>/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://flinkv2:8088/cluster/app/application_1701673087217_0001 Then click on links to logs of each attempt.
. Failing the application.
2023-12-04 15:06:00,919 INFO mapreduce.Job: Counters: 0

解决方法: 在 mapred-site.xml 中如下内容:

<!--用于集群跑mr任务-->
    <property>
        <name>mapreduce.application.classpath</name>
        <value>$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/*:$HADOOP_MAPRED_HOME/share/hadoop/mapreduce/lib/*</value>
    </property>
    <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>
    <property>
    <name>yarn.application.classpath</name>
    <value>/opt/software/hadoop/etc/hadoop,
    /opt/software/hadoop/share/hadoop/common/lib/*,
    /opt/software/hadoop/share/hadoop/common/*,
    /opt/software/hadoop/share/hadoop/hdfs,
    /opt/software/hadoop/share/hadoop/hdfs/lib/*,
    /opt/software/hadoop/share/hadoop/hdfs/*,
    /opt/software/hadoop/share/hadoop/mapreduce/lib/*,
    /opt/software/hadoop/share/hadoop/mapreduce/*,
    /opt/software/hhadoop/share/hadoop/yarn,
    /opt/software/hadoop/share/hadoop/yarn/lib/*,
    /opt/software/hadoop/share/hadoop/yarn/*
    </value>
    </property>

Could not find or load main class org.apache.hadoop.mapreduce.v2.app.MRAppMaster_第1张图片

再次运行:

你可能感兴趣的:(apache,hadoop,mapreduce)