当使用spark-submit提交作业时,我设置了master URL并给了他一个主类,例如:
spark-submit --class WordCount --master Spark://spark:7077 my.jar
但是在这个主类中,我的 Spark 上下文定义了另一个主 url :
SparkSession.builder().appName("Word2vec").master("local").
这让我很困惑,如果我使用 spark-submit
向独立集群的主节点 (spark://spark:7077
) 发送一个作业,会发生什么?使用 local
master 启动 SparkSession
?
在集群上执行时,SparkSession
master url 是否应该始终与 spark-submit
url 相同?
最佳答案
这些属性之间没有区别。如果两者都设置,则直接在应用程序中设置的属性优先。引用documentation :
Any values specified as flags or in the properties file will be passed on to the application and merged with those specified through SparkConf. Properties set directly on the SparkConf take highest precedence, then flags passed to spark-submit or spark-shell, then options in the spark-defaults.conf file. A few configuration keys have been renamed since earlier versions of Spark; in such cases, the older key names are still accepted, but take lower precedence than any instance of the newer key.
关于apache-spark - 主类中的Spark-submit master url和SparkSession master url有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38826670/