apache-spark - Spark中的客户端模式和集群模式有什么区别?
问题描述
我怀疑什么是客户端模式和集群模式。举个例子:
我有 test.py 有以下内容:
if __name__ == "__main__":
conf = (SparkConf()
.setAppName(appName)
.set("spark.executor.memory", ?)
.set('spark.driver.memory', ?)
.set('spark.executor.memoryOverhead',?)
.set("spark.network.timeout", ?)
.set("spark.files.overwrite", ?)
.set("spark.executor.heartbeatInterval", ?)
.set("spark.driver.maxResultSize", ?)
.set("spark.executor.instances", ?)
.set("spark.executor.cores", ?)
.set("spark.driver.cores", ?)
.set("spark.sql.shuffle.partitions", ?)
)
spark = SparkSession.builder.config(conf=conf).getOrCreate()
start_time = time.time()
sc = spark.sparkContext
sqlContext = SQLContext(sparkContext = sc)
我在 SSH linux 服务器上工作。为了能够运行 test.py,我可以做两个选择:
1- 使用以下命令保留节点:
salloc --time=03:00:00 --cpus-per-task=32 --mem=0 --account=def-myName
这个命令允许我保留一个节点三个小时。该节点具有以下规范:
Cores: 32
Available memory: 125 gb
CPU type: 2 x Intel E5-2683 v4 "Broadwell" @ 2.1Ghz
Storage: 2 x 480GB SSD
现在运行 test.py,我只需输入spark-submit test.py
. 这种方式叫客户端模式还是集群模式?如果是客户端模式,我该如何设置:
Master Memory:
Master Cores:
Number of Worker Nodes:
Memory per worker node (gb):
Cores per worker node:
2-我可以运行一个job.sh
where 它的定义如下:
#SBATCH --nodes=1
#SBATCH --time=
#SBATCH --mem=128000M
#SBATCH --cpus-per-task=
#SBATCH --ntasks-per-node=
#SBATCH --output=sparkjob-%j.out
#SBATCH --mail-type=ALL
#SBATCH --error=
## send mail to this address
#SBATCH --mail-user=
spark-submit --total-executor-cores xxx --driver-memory xxxx test.py
....
然后我执行代码sbatch job.sh
。这种方式叫集群方式吗?
解决方案
在客户端模式下,驱动程序(执行本地任务)设置在您运行的服务器上spark-submit
。执行器由您的资源管理器(yarn 或 mesos)在具有您请求的资源的任何节点上动态分配。
在集群模式下,驱动程序也由资源管理器动态分配,因此可以位于集群的任何节点上。
您可以在此处阅读更多内容https://stackoverflow.com/a/41142747/8467558。
部署模式的 spark-submit 内联命令是--deploy-mode
Usage: spark-submit [options] <app jar | python file | R file> [app arguments]
Usage: spark-submit --kill [submission ID] --master [spark://...]
Usage: spark-submit --status [submission ID] --master [spark://...]
Usage: spark-submit run-example [options] example-class [example args]
Options:
--master MASTER_URL spark://host:port, mesos://host:port, yarn,
k8s://https://host:port, or local (Default: local[*]).
--deploy-mode DEPLOY_MODE Whether to launch the driver program locally ("client") or
on one of the worker machines inside the cluster ("cluster")
(Default: client).
如果未设置,它将默认为您的spark-defaults.conf
配置值spark.submit.deployMode
。如果没有默认配置或未设置此值,它将是client
.
推荐阅读
- grep - 使用 Grep 命令搜索包含反斜杠的字符串
- python - 你可以在 python 类的 __init__ 中使用静态方法作为默认参数吗?
- android - 如何解决这个问题:对象作为 React Child 无效
- arrays - 在powershell中同时访问和使用json数组进行并行执行
- android - react-native-webview 无法解析 org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.11
- asp.net-core-webapi - 如何在 Azure Application Insights 中获取 Web 请求的响应大小
- python - 将 C++ 枚举类暴露给 Python 代码时出错
- swift - 如何在 Swift 中重置滑块值?
- authentication - 为什么我在使用 Microsoft 帐户外部登录时在 IdentityServer4 日志中看到“无效客户端”?
- javascript - 在JS中使用正则表达式基于字符串生成url