除了@Krishna,
如果您有mvn project,请在pom.xml 上使用mvn clean package。确保您的pom.xml 中有以下build 以生成fat-jar。 (这是我的情况,我是怎么做jar的)
<build><sourceDirectory>src</sourceDirectory>
<plugins><plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>assemble-all</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin></plugins>
</build>
更多详情:link
如果您有sbt project,请使用sbt clean assembly 生成fat-jar。为此,您需要以下配置,例如 build.sbt
assemblyJarName := "WordCountSimple.jar"
//
val meta = """META.INF(.)*""".r
assemblyMergeStrategy in assembly := {
case PathList("javax", "servlet", xs@_*) => MergeStrategy.first
case PathList(ps@_*) if ps.last endsWith ".html" => MergeStrategy.first
case n if n.startsWith("reference.conf") => MergeStrategy.concat
case n if n.endsWith(".conf") => MergeStrategy.concat
case meta(_) => MergeStrategy.discard
case x => MergeStrategy.first
}
还有plugin.sbt点赞:
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.13.0")
如需了解更多信息,请参阅 this 和 this。
到目前为止,主要目标是获取包含目标文件夹中所有依赖项的 fat-jar。使用该 jar 在集群中运行,如下所示:
hastimal@nm:/usr/local/spark$ ./bin/spark-submit --class com.hastimal.wordcount --master yarn-cluster --num-executors 15 --executor-memory 52g --executor-cores 7 --driver-memory 52g --driver-cores 7 --conf spark.default.parallelism=105 --conf spark.driver.maxResultSize=4g --conf spark.network.timeout=300 --conf spark.yarn.executor.memoryOverhead=4608 --conf spark.yarn.driver.memoryOverhead=4608 --conf spark.akka.frameSize=1200 --conf spark.io.compression.codec=lz4 --conf spark.rdd.compress=true --conf spark.broadcast.compress=true --conf spark.shuffle.spill.compress=true --conf spark.shuffle.compress=true --conf spark.shuffle.manager=sort /users/hastimal/wordcount.jar inputRDF/data_all.txt /output
这里我有inputRDF/data_all.txt /output 是两个参数。同样从工具的角度来看,我正在 Intellijas IDE 中构建。