天天看点

spark-Standalone 三种运行模式

一、驱动driver在集群运行模式, 以cluster方式提交时,port最好设置为6066,因为这种方式提交时,是以rest api方式提交application

bin/spark-submit \

--class org.apache.spark.examples.SparkPi \

--master spark://hadoop101:6066 \

--deploy-mode cluster       --executor-memory 1G \

--total-executor-cores 6 \

./examples/jars/spark-examples_2.11-2.1.1.jar 10

如果上边的端口6066换为7077,客服端屏幕输出会报错如下:

21/09/27 00:09:09 WARN rest.RestSubmissionClient: Unable to connect to server spark://hadoop101:7077.

Warning: Master endpoint spark://hadoop101:7077 was not a REST server. Falling back to legacy submission gateway instead.

但是在master的ui页面http://hadoop101:8080/依然有运行结果,但是建议还是用6066。

spark-Standalone 三种运行模式
spark-Standalone 三种运行模式
spark-Standalone 三种运行模式

 二、驱动driver在客户端运行模式(默认)

bin/spark-submit \

--class org.apache.spark.examples.SparkPi \

--master spark://hadoop101:7077 \

--deploy-mode client     --executor-memory 1G \

--total-executor-cores 6 \

./examples/jars/spark-examples_2.11-2.1.1.jar 10

结果直接在屏幕上输出

spark-Standalone 三种运行模式

 以上二种模式常在时间工作中,把程序打成jar包提交来运行。

三、启动 Spark-shell,用于学习和测试中快速运行程序

bin/spark-shell \

--master spark://hadoop101:7077

说明:

  • --master spark://hadoop101:7077指定要连接的集群的master
  • spark-Standalone 三种运行模式

继续阅读