spark 不同模式用途_Spark 的四种模式
1.spark主要有四種運行模式:Loca 、standalone、yarn、mesos。
1)Local模式:在一臺機器上,一般用于開發測試
2)standalone模式:完全獨立的spark集群,不依賴其他集群,分為Master和work。
客戶端向Master注冊應用,Master向work發送消息,依次啟動Driver,executor,Driver負責向executors發送任務消息。
3)yarn模式:依賴于hadoop集群,yarn資源調度框架,將應用提交給yarn,在ApplactionMaster(相當于Stand alone模式中的Master)中運行driver,在集群上調度資源,開啟excutor執行任務。
4)Spark on Mesos模式:類似于yarn模式,運行在Mesos集群上(Mesos是Apache下的開源分布式資源管理框架,它被稱為是分布式系統的內核。Mesos最初是由加州大學伯克利分校的AMPLab開發的,后在Twitter得到廣泛使用。)
2、啟動方式:sparkShell
spark-shell通過不同的參數控制采用何種模式進行。 涉及兩個參數:
--master MASTER_URL spark://host:port, mesos://host:port, yarn, or local.
--deploy-mode DEPLOY_MODE Whether to launch the driver program locally ("client") or
on one of the worker machines inside the cluster ("cluster")
(Default: client).
1)本地模式
./spark-shell --master local
./spark-shell --master local[2] # 本地運行,兩個worker線程,理想狀態下為本地CPU core數
2)standalone模式
./spark-shell --master spark://192.168.1.10:7077
3)yarn模式
./spark-shell --master yarn
./spark-shell --master yarn-client
#不支持這種模式
#./spark-shell --master yarn-cluster
./spark-shell --master yarn --deploy-mode client
#不支持這種模式
#./spark-shell --master yarn --deploy-mode cluster
spark job部署模式:
通過啟動spark-submit 形式提交作業任務時通過自定參數來指定作業部署模式。
eg:
//client模式
spark-submit --master yarn --deploy-mode client --class xxx --executor-memory 1g --executor-cores 2 --num-executors 4 xxx.jar 1000
//cluster模式
spark-submit --master yarn --deploy-mode cluster --class xxx --executor-memory 1g --executor-cores 2 --num-executors 4 xxx.jar 1000
------------------------
1.client
driver程序運行在client端。
2.cluster
driver程序運行在某個worker上。
注:spark-shell只能以client方式啟動。
總結
以上是生活随笔為你收集整理的spark 不同模式用途_Spark 的四种模式的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 吐血推荐几款优秀下载软件
- 下一篇: K3梅林固件