首页 > 解决方案 > Difference in running a spark application with sbt run or with spark-submit script

问题描述

I am new to Spark and as I am learning this framework, I figured out that, to the best of my knowledge, there are two ways for running a spark application when written in Scala:

  1. Package the project into a JAR file, and then run it with the spark-submit script.
  2. Running the project directly with sbt run.

I am wondering what the difference between those two modes of execution could be, especially when running with sbt run can throw a java.lang.InterruptedException when it runs perfectly with spark-submit.

Thanks!

标签: scalaapache-sparksbtspark-submit

解决方案


SBT是一个构建工具(我喜欢在 Linux 上运行),它并不一定意味着使用 Spark。碰巧它像 IntelliJ 一样用于 Spark 应用程序。

您可以在 SBT 控制台下的单个 JVM中打包运行应用程序,但不能大规模运行。因此,如果您创建了一个带有指定依赖项的 Spark 应用程序,SBT 将使用编译代码并创建一个包含所需依赖项等的 jar 文件以在本地运行。

您还可以在 SBT 中使用组装选项,它创建一个uber jarfat jar,其中包含您上传到集群并通过调用spark-submit运行的 jar 中包含的所有依赖项。因此,同样,如果您创建了一个带有指定依赖项的 Spark 应用程序,SBT 将通过汇编、编译代码并创建一个包含所有必需依赖项等的 uber jar 文件,但您需要发送给 Workers 的外部文件除外。在您的集群上运行(通常)。


推荐阅读