文章目录
简介
Spark Application 提交运行时部署模式 Deploy Mode ,表示的是 Driver Program 运行的地方。要么是提交应用的 Client:client ,要么就是集群中从节点(Standalone:Worker,YARN:NodeManager):cluster 。
默认值为 client,当在实际的开发环境中,尤其是生产环境,使用 cluster 部署模式提交应用运行。
Client 模式演示讲解
以 Spark Application 运行到 Standalone 集群上为例,前面提交运行圆周率PI或者词频统计 WordCount 程序时,默认 DeployMode 为Client,表示应用 Driver Program 运行在提交应用 Client 主机上(启动 JVM Process 进程),示意图如下:

运行圆周率PI程序,采用 client 模式,命令如下:
SPARK_HOME=/export/server/spark
${SPARK_HOME}/bin/spark-submit \
--master spark://master:7077,slave1:7077 \
--deploy-mode client \
--driver-memory 512m \
--executor-memory 512m \
--num-executors 1 \
--total-executor-cores 2 \
--class org.apache.spark.examples.SparkPi \
${SPARK_HOME}/examples/jars/spark-examples_2.11-2.4.5.jar \
10

Cluster 模式演示讲解
如果采用cluster模式运行应用,应用Driver Program运行在集群从节点Worker某台机器上,示意图如下:

假设运行圆周率PI程序,采用cluster模式,命令如下:
SPARK_HOME=/export/server/spark
${SPARK_HOME}/bin/spark-submit \
--master spark://master:7077,slave1:7077 \
--deploy-mode cluster \
--supervise \
--driver-memory 512m \
--executor-memory 512m \
--num-executors 1 \
--total-executor-cores 2 \
--class org.apache.spark.examples.SparkPi \
${SPARK_HOME}/examples/jars/spark-examples_2.11-2.4.5.jar \
10

运行时注意区别!!!

Cilent模式和Cluster模式的不同之处
Cluster和Client模式最最本质的区别是:Driver程序运行在哪里。
- cluster模式:生产环境中使用该模式
- Driver程序在YARN集群当中

本文深入解析了Spark在不同部署模式下的运行机制,包括Client模式和Cluster模式的特点与区别,以及这两种模式在YARN上的具体实现过程。此外,还探讨了在不同模式下Driver程序的位置及其对应用程序的影响。

1993

被折叠的 条评论
为什么被折叠?



