错误: 找不到或无法加载主类 org.apache.hadoop.mapreduce.v2.app.MRAppMaster

目录

报错信息:

说明:

报错截图:

解决步骤

1.输出路径信息(运行代码)

2.复制上面输出的路径,添加到hadoop下面的yarn-site.xml里面

3.每个节点都要添加相应的信息(完成后重启集群)

 4.继续运行jar包

5.验证结果


报错信息:

Container exited with a non-zero exit code 1. Error file: prelaunch.err.

错误: 找不到或无法加载主类 org.apache.hadoop.mapreduce.v2.app.MRAppMaster

说明:

今天在测试一个jar包在Hadoop102上面跑的时候报了一个错误!

jar包为mapreduce测试代码测试一下单词的统计结果的代码

报错截图:

错误: 找不到或无法加载主类 org.apache.hadoop.mapreduce.v2.app.MRAppMaster_第1张图片

 在我打完jar包运行执行语句时发现

[simon@hadoop102 ~]$  hadoop jar wc.jar mr_test1121.WordCount /input/testwc /input/testwc/result
2022-11-21 12:14:47,216 INFO client.RMProxy: Connecting to ResourceManager at Hadoop103/192.168.45.103:8032
2022-11-21 12:14:47,590 WARN mapreduce.JobResourceUploader: Hadoop command-line option parsing not performed. Implement the Tool interface and execute your application with ToolRunner to remedy this.
2022-11-21 12:14:47,603 INFO mapreduce.JobResourceUploader: Disabling Erasure Coding for path: /tmp/hadoop-yarn/staging/

说找不到主类,这里找了半天也没有排除掉,最后检查了以前的yarn的文件配置发现没有添加相应的路径信息yarn.application.classpath:

解决步骤

(首先正常关闭集群)

1.输出路径信息(运行代码)

hadoop classpath

会输出相应的路径信息

[simon@hadoop102 ~]$ hadoop classpath
/opt/module/hadoop-3.2.3/etc/hadoop:/opt/module/hadoop-3.2.3/share/hadoop/common/lib/*:/opt/module/hadoop-3.2.3/share/hadoop/common/*:/opt/module/hadoop-3.2.3/share/hadoop/hdfs:/opt/module/hadoop-3.2.3/share/hadoop/hdfs/lib/*:/opt/module/hadoop-3.2.3/share/hadoop/hdfs/*:/opt/module/hadoop-3.2.3/share/hadoop/mapreduce/lib/*:/opt/module/hadoop-3.2.3/share/hadoop/mapreduce/*:/opt/module/hadoop-3.2.3/share/hadoop/yarn:/opt/module/hadoop-3.2.3/share/hadoop/yarn/lib/*:/opt/module/hadoop-3.2.3/share/hadoop/yarn/*

2.复制上面输出的路径,添加到hadoop下面的yarn-site.xml里面

这里hadoop的路径我的是hadoop-3.2.3/etc/hadoop

        
                yarn.application.classpath
                你的路径信息(刚才复制的路径信息)
        

3.每个节点都要添加相应的信息(完成后重启集群)

启动起来后应该有的服务

错误: 找不到或无法加载主类 org.apache.hadoop.mapreduce.v2.app.MRAppMaster_第2张图片

 4.继续运行jar包

hadoop jar wc.jar(jar包文件) mr_test1121.WordCount(包名.类名) /input/testwc(hdfs对应要统计的文件路径) /input/testwc/result(hdfs输出的路径,没有会自动新建)

5.验证结果

successful!

错误: 找不到或无法加载主类 org.apache.hadoop.mapreduce.v2.app.MRAppMaster_第3张图片

 有问题评论区,看到第一时间回!

你可能感兴趣的:(hadoop,mapreduce,apache,hdfs,大数据)