spark 不同模式用途_Spark 的四种模式
1.spark主要有四種運(yùn)行模式:Loca 、standalone、yarn、mesos。
1)Local模式:在一臺(tái)機(jī)器上,一般用于開發(fā)測試
2)standalone模式:完全獨(dú)立的spark集群,不依賴其他集群,分為Master和work。
客戶端向Master注冊應(yīng)用,Master向work發(fā)送消息,依次啟動(dòng)Driver,executor,Driver負(fù)責(zé)向executors發(fā)送任務(wù)消息。
3)yarn模式:依賴于hadoop集群,yarn資源調(diào)度框架,將應(yīng)用提交給yarn,在ApplactionMaster(相當(dāng)于Stand alone模式中的Master)中運(yùn)行driver,在集群上調(diào)度資源,開啟excutor執(zhí)行任務(wù)。
4)Spark on Mesos模式:類似于yarn模式,運(yùn)行在Mesos集群上(Mesos是Apache下的開源分布式資源管理框架,它被稱為是分布式系統(tǒng)的內(nèi)核。Mesos最初是由加州大學(xué)伯克利分校的AMPLab開發(fā)的,后在Twitter得到廣泛使用。)
2、啟動(dòng)方式:sparkShell
spark-shell通過不同的參數(shù)控制采用何種模式進(jìn)行。 涉及兩個(gè)參數(shù):
--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] # 本地運(yùn)行,兩個(gè)worker線程,理想狀態(tài)下為本地CPU core數(shù)
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部署模式:
通過啟動(dòng)spark-submit 形式提交作業(yè)任務(wù)時(shí)通過自定參數(shù)來指定作業(yè)部署模式。
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程序運(yùn)行在client端。
2.cluster
driver程序運(yùn)行在某個(gè)worker上。
注:spark-shell只能以client方式啟動(dòng)。
總結(jié)
以上是生活随笔為你收集整理的spark 不同模式用途_Spark 的四种模式的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 吐血推荐几款优秀下载软件
- 下一篇: K3梅林固件