【2019-01-03】spark2.1使用yarn-clust

2019-01-28  本文已影响0人  学师大术

背景

版本 组件 一句话描述
2.1.0 spark sparksession初始化在线程中的spark程序,在yarn-client正常运行,yarn-cluster运行异常
/**在线程中启动一个sparksession**/
new Thread(new myJob).start()
/**myJob是个线程,启动sparksession**/
class myJob extends Runnable{
 override def run(): Unit = {
   val sparkSession = SparkSession.builder().enableHiveSupport().getOrCreate()
   val txtrdd= sparkSession.sql("show tables");
   txtrdd.show();
   sparkSession.stop();
 }
}
2019-01-28 10:32:41,500 | INFO  | [dispatcher-event-loop-4] | OutputCommitCoordinator stopped! | org.apache.spark.internal.Logging$class.logInfo(Logging.scala:54)
2019-01-28 10:32:41,510 | INFO  | [Driver] | Successfully stopped SparkContext | org.apache.spark.internal.Logging$class.logInfo(Logging.scala:54)
2019-01-28 10:32:41,512 | INFO  | [Driver] | Final app status: SUCCEEDED, exitCode: 0 | org.apache.spark.internal.Logging$class.logInfo(Logging.scala:54)
2019-01-28 10:32:41,526 | INFO  | [pool-1-thread-1] | Unregistering ApplicationMaster with SUCCEEDED | org.apache.spark.internal.Logging$class.logInfo(Logging.scala:54)

2.任务状态失败,异常提示为找不到_spark_conf.zip

Application application_1548509021440_0009 failed 2 times due to AM Container for appattempt_1548509021440_0009_000002 exited with exitCode: -1000
For more detailed output, check the application tracking page:https://172-16-56-32:26001/cluster/app/application_1548509021440_0009 Then click on links to logs of each attempt.
Diagnostics: File does not exist: hdfs://hacluster/user/zzltest/.sparkStaging/application_1548509021440_0009/__spark_conf__.zip
java.io.FileNotFoundException: File does not exist: hdfs://hacluster/user/zzltest/.sparkStaging/application_1548509021440_0009/__spark_conf__.zip
at org.apache.hadoop.hdfs.DistributedFileSystem$28.doCall(DistributedFileSystem.java:1529)
at org.apache.hadoop.hdfs.DistributedFileSystem$28.doCall(DistributedFileSystem.java:1521)

分析

根因

用户在线程中初始化sparkcontext,并且开启了多线程,导致一个jvm中存在多个sparkcontext,从而引起了上述错误。
看来sparkcontext不能在线程中初始化,至少FI版本中是这样的。 后续找个cdh版本再看下。

上一篇 下一篇

猜你喜欢

热点阅读