您的位置:首页 > 移动开发

实战 - 部署 Spark Application 到集群

2017-07-21 09:50 211 查看

命令格式

【命令式】 spark-submit [options] <app jar | python file> [app options]

【例子】
spark-submit --master spark://host:7077 --executor-memory 10g my_script.py


参数 :

1. –master :指定 cluster connetion URL , 可以有多种集群设置模式:

说明
spark://host:port连接到 spark standalone clustr ,默认端口为 7707
mesos://host:port连接到 mesos cluster , 默认端口为 5050
yarn连接到 Yarn cluster , 需要配置 HADOOP_CONF_DIR 环境变量
local运行在本地模式,单核运行
local
运行在本地模式,使用n核运行
local[*]运行在本地模式,使用本机所有核运行
2. 常用 [options]

选项说明
–masterspark 连接 url
–deploy-mode运行driver的模式, client , 则在执行spark-submit的机上运行; cluster ,则交给集群去指定一台机器运行;默认是 client 。
–classmain() 所在的 class ,要全名(针对java或scala)。
–name指定运行的应用名称,将会在 webui 上显示 。
–jars指定jar包列表,将添加到应用程序的 classpath 。
–files指定file列表,这些文件会被部署到集群节点上。
–py-files指定python文件、.zip文件 、 .eeg文件列表,将添加到应用程序的 PYTHONPATH 。
–executor-memory给executor申请内存。
–driver-memory给executor 申请内存。

部署到各cluster manager

部署 java 程序到 Standalone 使用 cluster 模式

./bin/spark-submit \
--master spark://hostname:7077 \
--deploy-mode cluster \
--class com.databricks.examples.SparkExample \
--name "Example Program" \
--jars dep1.jar,dep2.jar,dep3.jar \
--total-executor-cores 300  \
--executor-memory 10g \
myApp.jar "options" "to your application" "go here"


部署 python 程序到 yarn 使用 client 模式

export HADOOP_CONF_DIR=/opt/hadoop/conf
./bin/spark-submit \
--master yarn
--py-files somelib-1.2.egg,otherlib-4.4.zip,other-file.py \
--deploy-mode client \
--name "Example Program" \
--queue exampleQueue \
--num-executors 40 \
--executor-memory 10g \
my_script.py "options" "to your application" "go here"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: