1.standlone模式下
公式:execuoterNum = spark.cores.max/spark.executor.cores
相关参数在启动具体应用时指定
例如启动基于standlone模式的spark sql的thrift 接口时 设置 这两个参数
--total-executor-cores
--executor-cores
它们共同决定了当前应用 启动executor的个数
$SPARK_HOME/sbin/start-thriftserver.sh --executor-memory 20g --driver-memory 6g --total-executor-cores 288 --executor-cores 2
2.在yarn模式下
直接指定 –num-executors 这个参数
例如
$SPARK_HOME/bin/spark-submit --master yarn --deploy-mode cluster --class you.class.Name - -executor-memory 1g --executor-cores 1 --num-executors 8 --driver-memory 2g /you/jar.jar