简体   繁体   English

Spark sql在yarn cluster模式下抛出java.lang.OutOfMemoryError,但在yarn客户端模式下工作

[英]Spark sql throws java.lang.OutOfMemoryError in yarn cluster mode but works in yarn client mode

I have a simple hive query which works fine in yarn client mode using pyspark shell where as it throws me the below error when i run it in yarn-cluster mode. 我有一个简单的配置单元查询在使用pyspark shell的纱线客户端模式下工作正常,因为当我在纱线群集模式下运行它时,它会抛出以下错误。

Exception in thread "Thread-6" 
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Thread-6"
Exception in thread "Reporter" 
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "Reporter" 
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "sparkDriver-scheduler-1"

Cluster information: Hadoop 2.4, Spark 1.4.0-hadoop2.4 ,hive 0.13.1 The script takes 10 columns from a hive table and does some transformations and writes it to a file. 集群信息:Hadoop 2.4,Spark 1.4.0-hadoop2.4,hive 0.13.1该脚本从一个hive表中获取10列并进行一些转换并将其写入文件。

> num-executors 200 executor-memory 8G driver-memory 16G executor-cores 3

Full stack trace: 完整堆栈跟踪:

py4j-0.8.2.1-src.zip/py4j/protocol.py", line 300, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling o62.javaToPython.
: java.lang.OutOfMemoryError: PermGen space at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2570)
    at java.lang.Class.getDeclaredMethods(Class.java:1855)
    at org.apache.spark.util.ClosureCleaner$.org$apache$spark$util$ClosureCleaner$$clean(ClosureCleaner.scala:206)
    at org.apache.spark.util.ClosureCleaner$.clean(ClosureCleaner.scala:132)
    at org.apache.spark.SparkContext.clean(SparkContext.scala:1891)
    at org.apache.spark.rdd.RDD$$anonfun$mapPartitions$1.apply(RDD.scala:683)
    at org.apache.spark.rdd.RDD$$anonfun$mapPartitions$1.apply(RDD.scala:682)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:148)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:109)
    at org.apache.spark.rdd.RDD.withScope(RDD.scala:286)
    at org.apache.spark.rdd.RDD.mapPartitions(RDD.scala:682)
    at org.apache.spark.api.python.SerDeUtil$.javaToPython(SerDeUtil.scala:140)
    at org.apache.spark.sql.DataFrame.javaToPython(DataFrame.scala:1435)
    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 py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:231)
    at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:379)

java.lang.OutOfMemoryError: PermGen space at java.lang.ClassLoader.defineClass1(... java.lang.OutOfMemoryError:java.lang.ClassLoader.defineClass1中的PermGen空间(...

You are likely running out of "permanent generation" heap space in the driver's JVM. 您可能在驱动程序的JVM中耗尽了“永久生成”堆空间。 This area is used to store classes. 该区域用于存储类。 When we run in cluster mode, the JVM needs to load more classes (I think this is because the Application Manager runs inside the same JVM as the driver). 当我们以集群模式运行时,JVM需要加载更多类(我认为这是因为应用程序管理器在与驱动程序相同的JVM内运行)。 To increase the PermGen area, add the following option: 要增加PermGen区域,请添加以下选项:

--driver-java-options -XX:MaxPermSize=256M

See also https://plumbr.eu/outofmemoryerror/permgen-space 另见https://plumbr.eu/outofmemoryerror/permgen-space


When using HiveContext in your Python program, I've found that the following option is also needed: 在Python程序中使用HiveContext时,我发现还需要以下选项:

--files /usr/hdp/current/spark-client/conf/hive-site.xml

See also https://community.hortonworks.com/questions/27239/executing-spark-submit-with-yarn-cluster-mode-and.html 另请参见https://community.hortonworks.com/questions/27239/executing-spark-submit-with-yarn-cluster-mode-and.html


I've also wanted to specify a specific version of Python to use, which requires another option: 我还想指定要使用的特定Python版本,这需要另一个选项:

--conf spark.yarn.appMasterEnv.PYSPARK_PYTHON=/usr/local/bin/python2.7

See also https://issues.apache.org/jira/browse/SPARK-9235 另见https://issues.apache.org/jira/browse/SPARK-9235

Little addition to Mark's answer - sometimes Spark with HiveContext complains about OutOfMemoryError without any mention of PermGen, however only -XX:MaxPermSize helps. Mark的回答很少 - 有时Spark和HiveContext抱怨OutOfMemoryError而没有提到PermGen,但只有 -XX:MaxPermSize有帮助。

So if you dealing with OOM when Spark + HiveContext is used, also try -XX:MaxPermSize 因此,如果在使用Spark + HiveContext时处理OOM,也请尝试-XX:MaxPermSize

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spark客户端永远不会以纱线群集模式运行 - Spark client never ends running in yarn-cluster mode 对于在YARN上运行的spark应用程序,哪种部署模式更好 - 客户端或集群 - For spark applications running on YARN, which deploy mode is better - client or cluster 为什么集群模式下的YARN上的Spark会因“线程中的异常”驱动程序“java.lang.NullPointerException”而失败? - Why does Spark on YARN in cluster mode fail with “Exception in thread ”Driver“ java.lang.NullPointerException”? 纱线客户模式和纱线集群模式之间的差异 - Difference between yarn-client mode and yarn-cluster mode Spark-submit / spark-shell > yarn-client 和 yarn-cluster 模式的区别 - Spark-submit / spark-shell > difference between yarn-client and yarn-cluster mode Spark-yarn 中客户端模式下的 ApplicationMaster 如何工作? - How ApplicationMaster in Client mode in Spark-yarn works? 如何在集群模式下将Spark应用提交到YARN? - How to submit Spark application to YARN in cluster mode? 提交 PySpark 应用程序以在集群模式下触发 YARN - submitting PySpark app to spark on YARN in cluster mode 纱线群集模式下Spark作业的ClassNotFoundException - ClassNotFoundException for Spark job on Yarn-cluster mode 纱线和集群模式下打印spark命令 - Printing spark command in yarn and cluster mode
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM