解决A master URL must be set in your configuration错误
程序员文章站
2022-07-12 14:16:15
...
在运行spark的测试程序SparkPi时,点击运行,出现了如下错误:
Exception in thread "main" org.apache.spark.SparkException: A master URL must be set in your configuration
at org.apache.spark.SparkContext.<init>(SparkContext.scala:185)
at SparkPi$.main(SparkPi.scala:12)
at SparkPi.main(SparkPi.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
从提示中可以看出找不到程序运行的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–>edit configuration,在左侧点击该项目。在右侧VM options中输入“-Dspark.master=local”,指示本程序本地单线程运行,再次运行即可。
配置如图:
本文转载自csdn文章:解决A master URL must be set in your configuration错误
上一篇: Android聊天软件开发(基于网易云IM即时通讯)——发送图片消息(五)
下一篇: spark 异常解决:A master URL must be set in your configuration
推荐阅读
-
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程序报错排查: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