Spark spark-submit --jars arguments 想要逗号列表,如何声明一个 jars 目录?
Spark spark-submit --jars arguments wants comma list, how to declare a directory of jars?
在 Submitting Applications in the Spark docs, as of 1.6.0 and earlier 中,不清楚如何指定 --jars 参数,因为它显然不是 colon-separated class路径而不是目录扩展。
文档说 "Path to a bundled jar including your application and all dependencies. The URL must be globally visible inside of your cluster, for instance, an hdfs:// path or a file:// path that is present on all nodes."
Question: What are all the options for submitting a classpath with
--jars in the spark-submit script in $SPARK_HOME/bin? Anything undocumented that could be submitted as an improvement for docs?
我问是因为今天我测试 --jars 时,我们必须明确提供每个 jar 的路径:
/usr/local/spark/bin/spark-submit --class jpsgcs.thold.PipeLinkageData ---jars=local:/usr/local/spark/jars/groovy-all-2.3.3.jar,local:/usr/local/spark/jars/guava-14.0.1.jar,local:/usr/local/spark/jars/jopt-simple-4.6.jar,local:/usr/local/spark/jars/jpsgcs-core-1.0.8-2.jar,local:/usr/local/spark/jars/jpsgcs-pipe-1.0.6-7.jar /usr/local/spark/jars/thold-0.0.1-1.jar
我们选择 pre-populate 每个 worker 上 /usr/local/spark/jars 中所有 jar 的集群,似乎如果没有提供 local:/ file:/ 或 hdfs:,那么默认是 file:/ 并且 driver 通过 driver 使 jar 在网络服务器 运行 上可用。我选择了本地,如上。
而且我们似乎不需要将主 jar 放在 --jars 参数中,我还没有测试过最后一个参数中是否有其他 classes (application-jar arg per文档,即 /usr/local/spark/jars/thold-0.0.1-1.jar) 被运送给工人,或者如果我需要将 application-jar 放在 --jars 路径中以获取 class 未以 --class 命名。
(并使用 --deploy-mode 客户端授予 Spark 独立模式,您还必须在每个工作人员上放置 driver 的副本,但您事先不知道哪个工作人员会运行 driver)
使用 --jars 参数的一种方法(唯一方法?)是提供一个 comma-separated 明确命名的 jar 列表。我想出使用逗号的唯一方法是 Whosebug 的答案,它让我超越了文档,看到了命令行:
spark-submit --help
该命令的输出包含:
--jars JARS Comma-separated list of local jars to include on the driver
and executor classpaths.
今天我测试 --jars 时,我们必须明确提供每个 jar 的路径:
/usr/local/spark/bin/spark-submit --class jpsgcs.thold.PipeLinkageData ---jars=local:/usr/local/spark/jars/groovy-all-2.3.3.jar,local:/usr/local/spark/jars/guava-14.0.1.jar,local:/usr/local/spark/jars/jopt-simple-4.6.jar,local:/usr/local/spark/jars/jpsgcs-core-1.0.8-2.jar,local:/usr/local/spark/jars/jpsgcs-pipe-1.0.6-7.jar /usr/local/spark/jars/thold-0.0.1-1.jar
以这种方式它很容易工作..而不是单独指定每个 jar 版本..
#!/bin/sh
# build all other dependent jars in OTHER_JARS
JARS=`find ../lib -name '*.jar'`
OTHER_JARS=""
for eachjarinlib in $JARS ; do
if [ "$eachjarinlib" != "APPLICATIONJARTOBEADDEDSEPERATELY.JAR" ]; then
OTHER_JARS=$eachjarinlib,$OTHER_JARS
fi
done
echo ---final list of jars are : $OTHER_JARS
echo $CLASSPATH
spark-submit --verbose --class <yourclass>
... OTHER OPTIONS
--jars $OTHER_JARS,APPLICATIONJARTOBEADDEDSEPERATELY.JAR
使用 tr
unix 命令也可以像下面的例子一样提供帮助。
--jars $(echo /dir_of_jars/*.jar | tr ' ' ',')
在 Submitting Applications in the Spark docs, as of 1.6.0 and earlier 中,不清楚如何指定 --jars 参数,因为它显然不是 colon-separated class路径而不是目录扩展。
文档说 "Path to a bundled jar including your application and all dependencies. The URL must be globally visible inside of your cluster, for instance, an hdfs:// path or a file:// path that is present on all nodes."
Question: What are all the options for submitting a classpath with --jars in the spark-submit script in $SPARK_HOME/bin? Anything undocumented that could be submitted as an improvement for docs?
我问是因为今天我测试 --jars 时,我们必须明确提供每个 jar 的路径:
/usr/local/spark/bin/spark-submit --class jpsgcs.thold.PipeLinkageData ---jars=local:/usr/local/spark/jars/groovy-all-2.3.3.jar,local:/usr/local/spark/jars/guava-14.0.1.jar,local:/usr/local/spark/jars/jopt-simple-4.6.jar,local:/usr/local/spark/jars/jpsgcs-core-1.0.8-2.jar,local:/usr/local/spark/jars/jpsgcs-pipe-1.0.6-7.jar /usr/local/spark/jars/thold-0.0.1-1.jar
我们选择 pre-populate 每个 worker 上 /usr/local/spark/jars 中所有 jar 的集群,似乎如果没有提供 local:/ file:/ 或 hdfs:,那么默认是 file:/ 并且 driver 通过 driver 使 jar 在网络服务器 运行 上可用。我选择了本地,如上。
而且我们似乎不需要将主 jar 放在 --jars 参数中,我还没有测试过最后一个参数中是否有其他 classes (application-jar arg per文档,即 /usr/local/spark/jars/thold-0.0.1-1.jar) 被运送给工人,或者如果我需要将 application-jar 放在 --jars 路径中以获取 class 未以 --class 命名。
(并使用 --deploy-mode 客户端授予 Spark 独立模式,您还必须在每个工作人员上放置 driver 的副本,但您事先不知道哪个工作人员会运行 driver)
使用 --jars 参数的一种方法(唯一方法?)是提供一个 comma-separated 明确命名的 jar 列表。我想出使用逗号的唯一方法是 Whosebug 的答案,它让我超越了文档,看到了命令行:
spark-submit --help
该命令的输出包含:
--jars JARS Comma-separated list of local jars to include on the driver
and executor classpaths.
今天我测试 --jars 时,我们必须明确提供每个 jar 的路径:
/usr/local/spark/bin/spark-submit --class jpsgcs.thold.PipeLinkageData ---jars=local:/usr/local/spark/jars/groovy-all-2.3.3.jar,local:/usr/local/spark/jars/guava-14.0.1.jar,local:/usr/local/spark/jars/jopt-simple-4.6.jar,local:/usr/local/spark/jars/jpsgcs-core-1.0.8-2.jar,local:/usr/local/spark/jars/jpsgcs-pipe-1.0.6-7.jar /usr/local/spark/jars/thold-0.0.1-1.jar
以这种方式它很容易工作..而不是单独指定每个 jar 版本..
#!/bin/sh
# build all other dependent jars in OTHER_JARS
JARS=`find ../lib -name '*.jar'`
OTHER_JARS=""
for eachjarinlib in $JARS ; do
if [ "$eachjarinlib" != "APPLICATIONJARTOBEADDEDSEPERATELY.JAR" ]; then
OTHER_JARS=$eachjarinlib,$OTHER_JARS
fi
done
echo ---final list of jars are : $OTHER_JARS
echo $CLASSPATH
spark-submit --verbose --class <yourclass>
... OTHER OPTIONS
--jars $OTHER_JARS,APPLICATIONJARTOBEADDEDSEPERATELY.JAR
使用
tr
unix 命令也可以像下面的例子一样提供帮助。--jars $(echo /dir_of_jars/*.jar | tr ' ' ',')