bin/spark-submit腳本負責建立包含Spark以及其依賴的類路徑(classpath),它支持不同的集羣管理器以及Spark支持的加載模式。
/bin/spark-submit \
--class <main-class>
--master <master-url> \
--deploy-mode <deploy-mode> \
--conf <key>=<value> \
... # other options
<application-jar> \
[application-arguments]
一些常用的選項是:
--class :你的應用程序的入口點(如org.apache.spark.examples.SparkPi)
--master:集羣的master URL(如spark://23.195.26.187:7077)
--deploy-mode:在worker節點部署你的driver(cluster)或者本地作爲外部客戶端(client)。默認是client。
--conf :任意的Spark配置屬性,格式是key=value。
application-jar :包含應用程序以及其依賴的jar包的路徑。這個URL必須在集羣中全局可見,例如,存在於所有節點的 hdfs:// 路徑或 file:// 路徑
application-arguments :傳遞給主類的主方法的參數
spark-submit所有的可用選項:
# Run application locally on 8 cores
./bin/spark-submit \
--class org.apache.spark.examples.SparkPi \
--master local[8] \
/path/to/examples.jar \
100
# Run on a Spark Standalone cluster in client deploy mode
./bin/spark-submit \
--class org.apache.spark.examples.SparkPi \
--master spark://207.184.161.138:7077 \
--executor-memory 20G \
--total-executor-cores 100 \
/path/to/examples.jar \
1000
# Run on a Spark Standalone cluster in cluster deploy mode with supervise
./bin/spark-submit \
--class org.apache.spark.examples.SparkPi \
--master spark://207.184.161.138:7077 \
--deploy-mode cluster
--supervise
--executor-memory 20G \
--total-executor-cores 100 \
/path/to/examples.jar \
1000
# Run on a YARN cluster
export HADOOP_CONF_DIR=XXX
./bin/spark-submit \
--class org.apache.spark.examples.SparkPi \
--master yarn-cluster \ # can also be `yarn-client` for client mode
--executor-memory 20G \
--num-executors 50 \
/path/to/examples.jar \
1000
# Run a Python application on a Spark Standalone cluster
./bin/spark-submit \
--master spark://207.184.161.138:7077 \
examples/src/main/python/pi.py \
1000
用spark-submit啓動Spark應用程序
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.