1.使用hadoop classpath
2.将的到的内容添加到yarn-site.xml,mapred-site.xml
<property>
<name>yarn.application.classpath</name>
<value>/opt/apps/hadoop-3.2.4/etc/hadoop:/opt/apps/hadoop-3.2.4/share/hadoop/common/lib/*:/opt/apps/hadoop-3.2.4/share/hadoop/common/*:/opt/apps/hadoop-3.2.4/share/hadoop/hdfs:/opt/apps/hadoop-3.2.4/share/hadoop/hdfs/lib/*:/opt/apps/hadoop-3.2.4/share/hadoop/hdfs/*:/opt/apps/hadoop-3.2.4/share/hadoop/mapreduce/lib/*:/opt/apps/hadoop-3.2.4/share/hadoop/mapreduce/*:/opt/apps/hadoop-3.2.4/share/hadoop/yarn:/opt/apps/hadoop-3.2.4/share/hadoop/yarn/lib/*:/opt/apps/hadoop-3.2.4/share/hadoop/yarn/*</value>
</property>
如果还不行 可以借鉴以下内容
yarn-site.xml
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. See accompanying LICENSE file.
-->
<configuration>
<!-- 配置yarn的高可用 -->
<property>
<name>yarn.resourcemanager.ha.enabled</name>
<value>true</value>
</property>
<!-- 指定两个resourcemaneger的名称 -->
<property>
<name>yarn.resourcemanager.ha.rm-ids</name>
<value>rm1,rm2</value>
</property>
<!-- 配置rm1的主机 -->
<property>
<name>yarn.resourcemanager.hostname.rm1</name>
<value>node01</value>
</property>
<!-- 配置rm2的主机 -->
<property>
<name>yarn.resourcemanager.hostname.rm2</name>
<value>node03</value>
</property>
<!-- 开启yarn恢复机制 -->
<property>
<name>yarn.resourcemanager.recovery.enabled</name>
<value>true</value>
</property>
<!-- 执行rm恢复机制实现类 -->
<property>
<name>yarn.resourcemanager.store.class</name>
<value>org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore</value>
</property>
<!-- 配置zookeeper的地址 -->
<property>
<name>yarn.resourcemanager.zk-address</name>
<value>node01:2181,node02:2181,node03:2181</value>
</property>
<!-- 执行yarn集群的别名 -->
<property>
<name>yarn.resourcemanager.cluster-id</name>
<value>ns-yarn</value>
</property>
<!-- 指定nodemanager启动时加载server的方式为shuffle server -->
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<!-- 指定resourcemanager地址 -->
<property>
<name>yarn.resourcemanager.hostname</name>
<value>node03</value>
</property>
<!-- 是否启动一个线程检查每个任务正在使用的物理内存,如果任务超出分配量则直接将其杀死 -->
<property>
<name>yarn.nodemanager.pmem-check-enabled</name>
<value>false</value>
</property>
<!-- 是否启动一个线程检查每个任务正在使用的虚拟内存,如果任务超出分配量则直接将其杀死 -->
<property>
<name>yarn.nodemanager.vmem-check-enabled</name>
<value>false</value>
</property>
<property>
<name>yarn.application.classpath</name>
<value>/opt/apps/hadoop-3.2.4/etc/hadoop:/opt/apps/hadoop-3.2.4/share/hadoop/common/lib/*:/opt/apps/hadoop-3.2.4/share/hadoop/common/*:/opt/apps/hadoop-3.2.4/share/hadoop/hdfs:/opt/apps/hadoop-3.2.4/share/hadoop/hdfs/lib/*:/opt/apps/hadoop-3.2.4/share/hadoop/hdfs/*:/opt/apps/hadoop-3.2.4/share/hadoop/mapreduce/lib/*:/opt/apps/hadoop-3.2.4/share/hadoop/mapreduce/*:/opt/apps/hadoop-3.2.4/share/hadoop/yarn:/opt/apps/hadoop-3.2.4/share/hadoop/yarn/lib/*:/opt/apps/hadoop-3.2.4/share/hadoop/yarn/*</value>
</property>
<property>
<name>yarn.resourcemanager.webapp.address.rm1</name>
<value>node01:8088</value>
</property>
<property>
<name>yarn.resourcemanager.webapp.address.rm2</name>
<value>node03:8088</value>
</property>
</configuration>
mapred-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. See accompanying LICENSE file.
-->
<!-- Put site-specific property overrides in this file. -->
<configuration>
<!--在<configuration></configuration>中间添加一下内容-->
<!--使用yarn运行mapreduce程序【必须配置】-->
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<!--配置历史服务器【暂时不需要配置】-->
<property><!--MapReduce JobHistory Server地址-->
<name>mapreduce.jobhistory.address</name>
<value>node01:10020</value>
</property>
<!--MapReduce JobHistory Server Web界面地址-->
<property>
<name>mapreduce.jobhistory.webapp.address</name>
<value>node01:19888</value>
</property>
<property>
<name>mapreduce.application.classpath</name>
<value>/opt/apps/hadoop-3.2.4/etc/hadoop:/opt/apps/hadoop-3.2.4/share/hadoop/common/lib/*:/opt/apps/hadoop-3.2.4/share/hadoop/common/*:/opt/apps/hadoop-3.2.4/share/hadoop/hdfs:/opt/apps/hadoop-3.2.4/share/hadoop/hdfs/lib/*:/opt/apps/hadoop-3.2.4/share/hadoop/hdfs/*:/opt/apps/hadoop-3.2.4/share/hadoop/mapreduce/lib/*:/opt/apps/hadoop-3.2.4/share/hadoop/mapreduce/*:/opt/apps/hadoop-3.2.4/share/hadoop/yarn:/opt/apps/hadoop-3.2.4/share/hadoop/yarn/lib/*:/opt/apps/hadoop-3.2.4/share/hadoop/yarn/*</value>
</property>
</configuration>
1. List item