我试图在Scala API(Play框架)中运行SparkContext。当我将Spark master设置为“local”时,它工作正常,但是,当我将master设置为“YARN”时,它会引发异常:
[SparkException: Yarn application has already ended! It might have been killed or unable to launch application master.]
当我检查容器的日志时,我得到以下内容:
Error: Could not find or load main class org.apache.spark.deploy.yarn.ExecutorLauncher
如果我运行 spark-shell --master yarn 它运行SparkContext没有任何问题。
这是我的代码:
val sparkS = SparkSession.builder
.config("spark.hadoop.validateOutputSpecs", "false")
.config("spark.executor.memory", "4g")
.config("spark.driver.memory", "3g")
.config("spark.rpc.message.maxSize", "2047")
.config("SPARK_DIST_CLASSPATH", "/usr/local/spark/jars/*")
.config("spark.yarn.archive", "hdfs://localhost:54310/spark-libs.jar")
.config("spark.yarn.jars", "/usr/local/spark/jars/*")
.config("spark.executor.extraJavaOptions", "-XX:+PrintGCDetails -Dkey=value -Dnumbers="one two three"")
.config("spark.executor.extraLibraryPath", "/usr/local/hadoop-2.8.5/lib/native:/usr/local/hadoop-2.8.5/lib/native/Linux-amd64-64")
.config("HADOOP_CONF_DIR", "/usr/local/hadoop-2.8.5/etc/hadoop")
.config("spark.yarn.am.waitTime", "1d")
.master("yarn").getOrCreate
提交spark jar时你必须提到主类.Below是格式
./bin/spark-submit \
--class \
--master \
--deploy-mode \
--conf = \
... # other options
\
[application-arguments]
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。