累加器AC的使用方法 如何在Spark集群的work節(jié)點上啟動多個Executor?
如何在Spark集群的work節(jié)點上啟動多個Executor?1、設(shè)置每個executor使用的cpu數(shù)為4spark.executor.cores 42、限制cpu使用數(shù)量,這里會啟動3個execu
如何在Spark集群的work節(jié)點上啟動多個Executor?
1、設(shè)置每個executor使用的cpu數(shù)為4
spark.executor.cores 4
2、限制cpu使用數(shù)量,這里會啟動3個executor(12/4)
spark.cores.max 12
3、設(shè)置每個executor的內(nèi)存大小為8g
spark.executor.memory 12g
以上設(shè)置將會啟動3個executor,每個executor使用4cpu,12gRAM。
總共占用worker資源12cpu,36gRAM。
Spark1.6的源碼部分為:
protected final String EXECUTOR_MEMORY = "--executor-memory"protected final String TOTAL_EXECUTOR_CORES = "--total-executor-cores"protected final String EXECUTOR_CORES = "--executor-cores"
也可以在提交任務(wù)的時候添加:
SparkSubmit --class com.dyq.spark.MyClass --master:spark://master:7077 --total-executor-cores 12 --executor-cores 24 --executor-memory 12g
tip
在使用過程中發(fā)現(xiàn)如果使用spark1.5以下版本有時候會出現(xiàn)即使有資源也申請不到的情況。
SparkSQL對于重復(fù)的計算怎么優(yōu)化?
Spark sql是為了處理結(jié)構(gòu)化數(shù)據(jù)的一個spark 模塊。 不同于spark rdd的基本API,spark sql接口更多關(guān)于數(shù)據(jù)結(jié)構(gòu)本身與執(zhí)行計劃等更多信息。 在spark內(nèi)部,sql sql利用這些信息去更好地進(jìn)行優(yōu)化。 有如下幾種方式執(zhí)行spark sql:SQL,DataFramesAPI與Datasets API。當(dāng)相同的計算引擎被用來執(zhí)行一個計算時,有不同的API和語言種類可供選擇。 這種統(tǒng)一性意味著開發(fā)人員可以來回輕松切換各種最熟悉的API來完成同一個計算工作。