首页 > 解决方案 > 如何在 GCP 中以集群模式运行 Spark 作业?

问题描述

在 GCP 中,我们希望在 data[proc 集群上以集群模式运行 spark 作业。目前我们正在使用以下命令:-

gcloud dataproc jobs submit spark --cluster xxxx-xxxx-dataproc-cluster01 --region us-west2 --xxx.xxxx.xxx.xxx.xxx.xxx.xxxx.xxxx --jars gs://xxx-xxxx-poc/cluster-compute/lib/xxxxxxxx-cluster-computation-jar-0.0.1-SNAPSHOT-allinone.jar --properties=spark:spark.submit.deployMode=cluster --properties=spark.driver.extraClassPath=/xxxx/xxxx/xxxx/ -- -c xxxxxxxx -a

但是,使用上述作业是在本地模式下提交的。我们需要在集群模式下运行。

标签: apache-sparkgoogle-cloud-platformgoogle-cloud-dataproc

解决方案


您可以通过指定以下内容以集群模式运行它--properties spark.submit.deployMode=cluster

在您的示例中, deployMode 看起来不正确。

--properties=spark:spark.submit.deployMode=cluster 

看起来spark:是多余的。

这是作业提交的完整命令

gcloud dataproc jobs submit pyspark --cluster XXXXX --region us-central1 --properties="spark.submit.deployMode=cluster" gs://dataproc-examples/pyspark/hello-world/hello-world.py

下面是集群模式下运行的作业截图

Spark 作业配置

更新

要传递以下多个属性是 dataproc 作业提交

gcloud dataproc jobs submit pyspark --cluster cluster-e0a0 --region us-central1 --properties="spark.submit.deployMode=cluster","spark.driver.extraClassPath=/xxxxxx/configuration/cluster-mode/" gs://dataproc-examples/pyspark/hello-world/hello-world.py

运行下面的作业是显示 deployMode 是 Cluster 并且还设置了额外的类路径的屏幕截图

多个属性


推荐阅读