Hadoop3.1.3下成功安装后,进行MapReduce操作出现错误:
错误: 找不到或无法加载主类org.apache.hadoop.mapreduce.v2.app.MRAppMaster

解决办法:
① 在命令行下输入如下命令,并将返回的地址复制。

$ hadoop classpath
/usr/local/hadoop/hadoop-3.1.3/etc/hadoop:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/common/lib/*:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/common/*:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/hdfs:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/hdfs/lib/*:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/hdfs/*:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/mapreduce/lib/*:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/mapreduce/*:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/yarn:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/yarn/lib/*:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/yarn/*

② 编辑yarn-site.xml

vim yarn-site.xml
#添加如下内容
<configuration>
    <property>
        <name>yarn.application.classpath</name>
        <value>/usr/local/hadoop/hadoop-3.1.3/etc/hadoop:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/common/lib/*:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/common/*:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/hdfs:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/hdfs/lib/*:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/hdfs/*:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/mapreduce/lib/*:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/mapreduce/*:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/yarn:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/yarn/lib/*:/usr/local/hadoop/hadoop-3.1.3//share/hadoop/yarn/*</value>
    </property>
</configuration>

将yarn-site.xml分发到集群的其他节点,设置完毕后重启Hadoop集群,重新运行刚才的MapReduce程序,成功运行。

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐