1.修改hadoop配置文件yarn-site.xml
<!-- 物理内存 -->
<property>
<name>yarn.nodemanager.pmem-check-enabled</name>
<value>false</value>
</property>
<!-- 虚拟内存 -->
<property>
<name>yarn.nodemanager.vmem-check-enabled</name>
<value>false</value>
</property>
2.修改spark配置文件spark-env.sh
YARN_CONF_DIR=/opt/module/hadoop-2.7.6/etc/hadoop
3.测试代码
bin/spark-submit --class org.apache.spark.examples.SparkPi \
--master yarn \
--deploy-mode client \
./examples/jars/spark-examples*.jar \
10