Spark - Error “A master URL must be set in your configuration” when submitting an app

后端 未结 16 1981
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-02 07:31

I have an Spark app which runs with no problem in local mode,but have some problems when submitting to the Spark cluster.

The error msg are as follows:



        
16条回答
  •  时光说笑
    2020-12-02 08:06

    The default value of "spark.master" is spark://HOST:PORT, and the following code tries to get a session from the standalone cluster that is running at HOST:PORT, and expects the HOST:PORT value to be in the spark config file.

    SparkSession spark = SparkSession
        .builder()
        .appName("SomeAppName")
        .getOrCreate();
    

    "org.apache.spark.SparkException: A master URL must be set in your configuration" states that HOST:PORT is not set in the spark configuration file.

    To not bother about value of "HOST:PORT", set spark.master as local

    SparkSession spark = SparkSession
        .builder()
        .appName("SomeAppName")
        .config("spark.master", "local")
        .getOrCreate();
    

    Here is the link for list of formats in which master URL can be passed to spark.master

    Reference : Spark Tutorial - Setup Spark Ecosystem

提交回复
热议问题