1.前置软件:
JDK1.8
2.修改配置文件:
cp slaves.template slaves
vi slaves
添加从节点:
slave1
slave2
cp spark-env.sh.template spark-env.sh
vi spark-env.sh
添加环境变量:
export SPARK_MASTER_HOST=master
export SPARK_MASTER_PORT=7077
export SPARK_WORKER_CORES=2
export SPARK_WORKER_MEMORY=3g
export JAVA_HOME=/opt/module/jdk1.8.0_171
3.基于yarn 提交任务有可能报错虚拟内存不足
在每台节点中的yarn-site.xml中配值关闭虚拟内存检查
<property>
<name>yarn.nodemanager.vmem-check-enabled</name>
<value>false</value>
</property>
4.Standalone提交命令:
./bin/spark-submit --master spark://master:7077 --class org.apache.spark.examples.SparkPi ./examples/jars/spark-examples_2.11-2.3.2.jar 100
5.YARN提交命令:
spark-env.sh配置:export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
./bin/spark-submit --master yarn --class org.apache.spark.examples.SparkPi ./examples/jars/spark-examples_2.11-2.3.2.jar 100
6.进入webUI界面
http://master:8080/(端口7070是提交任务用的)