我使用spark summit命令执行spark作业,参数如下:
spark-submit --master yarn-cluster --driver-cores 2 \
--driver-memory 2G --num-executors 10 \
--executor-cores 5 --executor-memory 2G \
--class com.spark.sql.jdbc.SparkDFtoOracle2 \
Spark-hive-sql-Dataframe-0.0.1-SNAPSHOT-jar-with-dependencies.jar
现在我想使用spark的动态资源分配来执行相同的程序。在执行spark程序时,请您帮助使用动态资源分配。
2条答案
按热度按时间u5rb5r591#
我刚刚用spark的动态资源分配做了一个小演示。代码在我的github上。具体来说,演示版就在这个版本中。
8yoxcaq72#
在spark动态分配中
spark.dynamicAllocation.enabled
需要设置为true
因为它是false
默认情况下。这需要
spark.shuffle.service.enabled
设置为true
,因为Spark应用在Yarn上运行。选中此链接可在yarn中的每个nodemanager上启动shuffle服务。以下配置也与此相关:
这些选项可以配置为以3种方式激发应用程序
1从spark提交
--conf <prop_name>=<prop_value>
```spark-submit --master yarn-cluster
--driver-cores 2
--driver-memory 2G
--num-executors 10
--executor-cores 5
--executor-memory 2G
--conf spark.dynamicAllocation.minExecutors=5
--conf spark.dynamicAllocation.maxExecutors=30
--conf spark.dynamicAllocation.initialExecutors=10 \ # same as --num-executors 10
--class com.spark.sql.jdbc.SparkDFtoOracle2
Spark-hive-sql-Dataframe-0.0.1-SNAPSHOT-jar-with-dependencies.jar
val conf: SparkConf = new SparkConf()
conf.set("spark.dynamicAllocation.minExecutors", "5");
conf.set("spark.dynamicAllocation.maxExecutors", "30");
conf.set("spark.dynamicAllocation.initialExecutors", "10");
.....