org.apache.spark.SparkException: A master URL must be set in your configuration详解大数据

14/05/30 16:04:23 ERROR UserGroupInformation: PriviledgedActionException as:jnleec (auth:SIMPLE) cause:java.lang.reflect.InvocationTargetException 
Exception in thread "Thread-3" java.lang.reflect.UndeclaredThrowableException 
	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1504) 
	at org.apache.spark.deploy.SparkHadoopUtil.runAsUser(SparkHadoopUtil.scala:41) 
	at org.apache.spark.deploy.yarn.ApplicationMaster$$anon$2.run(ApplicationMaster.scala:159) 
Caused by: java.lang.reflect.InvocationTargetException 
	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 org.apache.spark.deploy.yarn.ApplicationMaster$$anon$2$$anonfun$run$1.apply$mcV$sp(ApplicationMaster.scala:165) 
	at org.apache.spark.deploy.SparkHadoopUtil$$anon$1.run(SparkHadoopUtil.scala:42) 
	at org.apache.spark.deploy.SparkHadoopUtil$$anon$1.run(SparkHadoopUtil.scala:41) 
	at java.security.AccessController.doPrivileged(Native Method) 
	at javax.security.auth.Subject.doAs(Subject.java:415) 
	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1491) 
	... 2 more 
Caused by: org.apache.spark.SparkException: A master URL must be set in your configuration 
	at org.apache.spark.SparkContext.<init>(SparkContext.scala:113) 
	at org.apache.spark.api.java.JavaSparkContext.<init>(JavaSparkContext.scala:47) 
	at com.test.JavaSparkPi.main(JavaSparkPi.java:21) 
	... 12 more 
Exception in thread "main" java.lang.AssertionError: assertion failed 
	at scala.Predef$.assert(Predef.scala:165) 
	at org.apache.spark.deploy.yarn.ApplicationMaster.waitForSparkContextInitialized(ApplicationMaster.scala:201) 
	at org.apache.spark.deploy.yarn.ApplicationMaster.run(ApplicationMaster.scala:105) 
	at org.apache.spark.deploy.yarn.ApplicationMaster$.main(ApplicationMaster.scala:443) 
	at org.apache.spark.deploy.yarn.ApplicationMaster.main(ApplicationMaster.scala) 
14/05/30 16:04:33 INFO ApplicationMaster: AppMaster received a signal.

错误原因,需要为spark设置master url

如果选择的部署模式是standalone且部署到你配置的这个集群上,可以指定 MASTER=spark://ubuntu:7070

下面解答spark在那里指定master URL的问题:
1.通过spark shell,执行后进入交互界面

MASTER=spark://IP:PORT ./bin/spark-shell

2.程序内指定(可以通过参数传入)

val conf = new SparkConf() 
             .setMaster(...) 
val sc = new SparkContext(conf)

传递给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。

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/9544.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论