4

209/5000 您好,我想将选项“--deploy-mode cluster”添加到我的代码 scala 中:

  val sparkConf = new SparkConfig ().setMaster ("spark: //192.168.60.80:7077")

不使用shell(命令.\Spark-submit)

我想在 scala 中使用“spark.submit.deployMode”

4

2 回答 2

7

使用 SparkConfig:

//set up the spark configuration and create contexts
val sparkConf = new SparkConf().setAppName("SparkApp").setMaster("spark: //192.168.60.80:7077")

val sc = new SparkContext(sparkConf).set("spark.submit.deployMode", "cluster")

使用 SparkSession:

val spark = SparkSession
   .builder()
   .appName("SparkApp")
   .master("spark: //192.168.60.80:7077")
   .config("spark.submit.deployMode","cluster")
   .enableHiveSupport()
   .getOrCreate()
于 2017-05-12T09:56:51.670 回答
2

您可以使用

 val sparkConf = new SparkConf ().setMaster ("spark: //192.168.60.80:7077").set("spark.submit.deployMode","cluster")
于 2017-05-11T12:59:20.067 回答