Spark提交---packages vs --jars

Jak*_*ke 3 java scala cassandra apache-spark

有人可以解释--packages--jars提交火花脚本之间的区别吗?

nohup ./bin/spark-submit   --jars ./xxx/extrajars/stanford-corenlp-3.8.0.jar,./xxx/extrajars/stanford-parser-3.8.0.jar \
--packages datastax:spark-cassandra-connector_2.11:2.0.7 \
--class xxx.mlserver.Application \
--conf spark.cassandra.connection.host=192.168.0.33 \
--conf spark.cores.max=4 \
--master spark://192.168.0.141:7077  ./xxx/xxxanalysis-mlserver-0.1.0.jar   1000  > ./logs/nohup.out &
Run Code Online (Sandbox Code Playgroud)

另外,--packages如果依赖关系在我的应用程序中,我是否需要配置pom.xml?(我问是因为我只是通过更改版本来炸毁我的应用程序,--packages而忘记了在中对其进行更改pom.xml

我正在使用--jars当前版本,因为jar很大(超过100GB),因此减慢了有阴影的jar的编译速度。我承认我不确定为什么要使用--packages其他软件,因为我正在遵循datastax文档

Suk*_*aar 11

如果您这样做spark-submit --help,它将显示:

--jars JARS                 Comma-separated list of jars to include on the driver
                              and executor classpaths.

--packages                  Comma-separated list of maven coordinates of jars to include
                              on the driver and executor classpaths. Will search the local
                              maven repo, then maven central and any additional remote
                              repositories given by --repositories. The format for the
                              coordinates should be groupId:artifactId:version.
Run Code Online (Sandbox Code Playgroud)

如果是--jars

然后spark不会击中maven,但它将在本地文件系统中搜索指定的jar,它也支持以下URL方案hdfs / http / https / ftp。

所以如果是--packages

然后spark将在本地Maven存储库中搜索特定的软件包,然后在Central Maven存储库或--repositories提供的任何存储库中搜索,然后将其下载。

现在回到您的问题:

另外,如果依赖关系在我的应用程序pom.xml中,我是否需要--packages配置?

回答:否,如果您不是直接在jar中导入/使用类,而是需要通过某些类加载器或服务加载器(例如JDBC驱动程序)加载类。是的,否则。

顺便说一句,如果您在pom.xml中使用特定版本的jar,那么为什么不制作应用程序的uber / fat jar或在--jars参数中提供依赖项jar ?而不是使用--packages

链接参考:

激发高级依赖管理

将罐子添加到火花作业提交