org.apache.spark.SparkException: A master URL must be set in your configuration
程序员文章站
2022-07-12 14:16:27
...
org.apache.spark.SparkException: A master URL must be set in your configuration
错误
org.apache.spark.SparkException: A master URL must be set in your configuration
at org.apache.spark.SparkContext.<init>(SparkContext.scala:379) ~[spark-core_2.11-2.1.4-SNAPSHOT.jar:2.1.4-SNAPSHOT]
at org.apache.spark.SparkContext$.getOrCreate(SparkContext.scala:2323) [spark-core_2.11-2.1.4-SNAPSHOT.jar:2.1.4-SNAPSHOT]
at org.apache.spark.sql.SparkSession$Builder$$anonfun$6.apply(SparkSession.scala:876) [spark-sql_2.11-2.1.4-SNAPSHOT.jar:2.1.4-SNAPSHOT]
at org.apache.spark.sql.SparkSession$Builder$$anonfun$6.apply(SparkSession.scala:868) [spark-sql_2.11-2.1.4-SNAPSHOT.jar:2.1.4-SNAPSHOT]
at scala.Option.getOrElse(Option.scala:121) [scala-library-2.11.8.jar:na]
at org.apache.spark.sql.SparkSession$Builder.getOrCreate(SparkSession.scala:868) [spark-sql_2.11-2.1.4-SNAPSHOT.jar:2.1.4-SNAPSHOT]
at org.apache.spark.examples.sql.JavaSparkSQLExample.main(JavaSparkSQLExample.java:96) [classes/:na]
从提示中可以看出找不到程序运行的master,此时需要配置环境变量。
传递给spark的master url可以有如下几种:
local 本地单线程
local[K] 本地多线程(指定K个内核)
local[*] 本地多线程(指定所有可用内核)
spark://HOST:PORT 连接到指定的 Spark standalone cluster master,需要指定端口。
mesos://HOST:PORT 连接到指定的 Mesos 集群,需要指定端口。
yarn-client客户端模式 连接到 YARN 集群。需要配置 HADOOP_CONF_DIR。
yarn-cluster集群模式 连接到 YARN 集群。需要配置 HADOOP_CONF_DIR。
项目右击--> Run As --> Run Configurations --> arguments --> VM arguments 设置为“-Dspark.master=local”
推荐阅读
-
IDEA开发SparkSQL报错:org.apache.spark.SparkException: A master URL must be set in your configuration
-
IDEA使用SparkSession读取Json文件报错 A master URL must be set in your configuration
-
运行Spark程序时出现 Exception in thread “main“ org.apache.spark.SparkException: A master URL must be set
-
Spark程序报错排查:A master URL must be set in your configuration
-
异常解决:A master URL must be set in your configuration
-
org.apache.spark.SparkException: A master URL must be set in your configuration
-
解决A master URL must be set in your configuration错误
-
spark 异常解决:A master URL must be set in your configuration
-
Spark异常:A master URL must be set in your configuration处理记录
-
本地开发Spark,运行JavaSparkPi例子报错:A master URL must be set in your configuration