1.Spark Submit任務(wù)提交

本文基于http://www.louisvv.com/archives/1340.html修改,感謝原作者。
Spark源碼版本: 2.1.0


Spark在集群上的運(yùn)行方式.png

Spark在集群上的運(yùn)行方式及相關(guān)概念

Spark應(yīng)用程序在集群上以獨(dú)立的進(jìn)程集運(yùn)行,整個(gè)的任務(wù)執(zhí)行過程如下:

  1. 用戶提交編寫的程序(Driver Program),Driver初始化SparkContext對(duì)象,SparkContext負(fù)責(zé)將應(yīng)用程序在集群上啟動(dòng)運(yùn)行;

  2. SparkContext連接到Cluster Manager,申請(qǐng)資源,注冊(cè)Application;

  3. SparkContext連接到Cluster Manager后,Cluster Manager根據(jù)申請(qǐng)的資源,在集群中的Worker節(jié)點(diǎn)上創(chuàng)建并啟動(dòng)Executor;

  4. 啟動(dòng)Executor后,Executor將注冊(cè)信息發(fā)送給Driver,告訴Driver,Executor已添加;

  5. SparkContext初始化過程中會(huì)創(chuàng)建并啟動(dòng)DAGScheduler,DAGScheduler將用戶編寫的程序轉(zhuǎn)化為Task,DAGScheduler將Task發(fā)送給指定Executor,進(jìn)行任務(wù)計(jì)算 ;

  6. Executor將Task計(jì)算結(jié)果返回給Driver,Spark任務(wù)計(jì)算完畢,一系列處理關(guān)閉Spark任務(wù)。


提交Spark程序:

從Spark任務(wù)的第一步開始,如何提交用戶編寫的程序?Spark提交程序
使用$SPARK_HOME/bin目錄下的 spark-submit 腳本去提交用戶的程序

spark-sumbit腳本提交示例.png
# 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 \
  --deploy-mode cluster \  # can be 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

# Run on a Mesos cluster in cluster deploy mode with supervise
./bin/spark-submit \
  --class org.apache.spark.examples.SparkPi \
  --master mesos://207.184.161.138:7077 \
  --deploy-mode cluster \
  --supervise \
  --executor-memory 20G \
  --total-executor-cores 100 \
  http://path/to/examples.jar \
  1000

未完待續(xù)。。。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1、 性能調(diào)優(yōu) 1.1、 分配更多資源 1.1.1、分配哪些資源? Executor的數(shù)量 每個(gè)Executor所...
    Frank_8942閱讀 4,840評(píng)論 2 36
  • 1.1、 分配更多資源 1.1.1、分配哪些資源? Executor的數(shù)量 每個(gè)Executor所能分配的CPU數(shù)...
    miss幸運(yùn)閱讀 3,283評(píng)論 3 15
  • spark-submit的時(shí)候如何引入外部jar包 在通過spark-submit提交任務(wù)時(shí),可以通過添加配置參數(shù)...
    博弈史密斯閱讀 3,023評(píng)論 1 14
  • Apache Spark 是專為大規(guī)模數(shù)據(jù)處理而設(shè)計(jì)的快速通用的計(jì)算引擎。Spark是UC Berkeley AM...
    大佛愛讀書閱讀 2,979評(píng)論 0 20
  • Apache Spark是一個(gè)圍繞速度、易用性和復(fù)雜分析構(gòu)建的大數(shù)據(jù)處理框架,最初在2009年由加州大學(xué)伯克利分校...
    達(dá)微閱讀 663評(píng)論 0 0

友情鏈接更多精彩內(nèi)容