spark shell运行模式小记

5,111次阅读
没有评论

共计 1459 个字符,预计需要花费 4 分钟才能阅读完成。

集群经常会增加相应的node节点,但是相应的环境有没有及时更新,有的时候因为某个节点环境没有配置好导致程序跑挂了,所以有的时候需要本地模式仅在driver跑相应的测试代码,记录一下当前的几种运行模式

  • 本地模式

Spark单机运行,一般用于开发测试。

  • Standalone模式

构建一个由Master+Slave构成的Spark集群,Spark运行在集群中。

  • Spark on Yarn模式

Spark客户端直接连接Yarn。不需要额外构建Spark集群。

  • Spark on Mesos模式

Spark客户端直接连接Mesos。不需要额外构建Spark集群。

启动方式: spark-shell.sh(Scala)

spark-shell通过不同的参数控制采用何种模式进行。 涉及两个参数:

1
2
3
4
--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).

–master参数用于指定采用哪种运行模式。
对于Spark on Yarn模式和Spark on Mesos模式还可以通过 –deploy-mode参数控制Drivers程序的启动位置。

  • 进入本地模式:
./spark-shell --master local
./spark-shell --master local[2]  # 本地运行,两个worker线程,理想状态下为本地CPU core数
  • 进入Standalone模式:
./spark-shell --master spark://192.168.1.10:7077

备注:测试发现MASTER_URL中使用主机名替代IP地址无法正常连接(hosts中有相关解析记录),即以下命令连接不成功:

./spark-shell --master spark://ctrl:7077  # 连接失败
  • Spark on Yarn模式
1
2
3
4
5
6
7
./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

备注:Yarn的连接信息在Hadoop客户端的配置文件中指定。通过spark-env.sh中的环境变量HADOOPCONFDIR指定Hadoop配置文件路径。

  • Spark on Mesos模式:
./spark-shell --master mesos://host:port
./spark-shell --master mesos://host:port --deploy-mode client
./spark-shell --master mesos://host:port --deploy-mode cluster

启动方式: pyspark(Python)

参数及用法与Scala语言的spark-shell相同,比如:

pyspark --master local[2]

参考http://blog.cheyo.net/29.html

正文完
请博主喝杯咖啡吧!
post-qrcode
 
admin
版权声明:本站原创文章,由 admin 2017-08-16发表,共计1459字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
评论(没有评论)
验证码