报错信息:
Container exited with a non-zero exit code 1. Error file: prelaunch.err.
错误: 找不到或无法加载主类 org.apache.hadoop.mapreduce.v2.app.MRAppMaster
说明:
今天在测试一个jar包在Hadoop102上面跑的时候报了一个错误!
jar包为mapreduce测试代码测试一下单词的统计结果的代码
报错截图:
在我打完jar包运行执行语句时发现
1. [simon@hadoop102 ~]$ hadoop jar wc.jar mr_test1121.WordCount /input/testwc /input/testwc/result 2. 2022-11-21 12:14:47,216 INFO client.RMProxy: Connecting to ResourceManager at Hadoop103/192.168.45.103:8032 3. 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. 4. 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
会输出相应的路径信息
1. [simon@hadoop102 ~]$ hadoop classpath 2. /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
1. <property> 2. <name>yarn.application.classpath</name> 3. <value>你的路径信息(刚才复制的路径信息)</value> 4. </property>
3.每个节点都要添加相应的信息(完成后重启集群)
启动起来后应该有的服务
4.继续运行jar包
hadoop jar wc.jar(jar包文件) mr_test1121.WordCount(包名.类名) /input/testwc(hdfs对应要统计的文件路径) /input/testwc/result(hdfs输出的路径,没有会自动新建)
5.验证结果
successful!