gpt4 book ai didi

apache-spark - Spark sql 在 yarn 集群模式下抛出 java.lang.OutOfMemoryError 但在 yarn 客户端模式下工作

转载 作者:行者123 更新时间:2023-12-02 03:23:24 25 4
gpt4 key购买 nike

我有一个简单的配置单元查询,它在使用 pyspark shell 的 yarn 客户端模式下运行良好,当我在 yarn-cluster 模式下运行它时,它会抛出以下错误。

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"

集群信息:Hadoop 2.4、Spark 1.4.0-hadoop2.4、hive 0.13.1该脚本从一个配置单元表中获取 10 列并进行一些转换并将其写入文件。

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

完整堆栈跟踪:

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(...

您可能用完了驱动程序 JVM 中的“永久代”堆空间。该区域用于存储类。当我们以集群模式运行时,JVM 需要加载更多的类(我认为这是因为应用程序管理器与驱动程序运行在同一个 JVM 中)。要增加 PermGen 区域,请添加以下选项:

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

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


在 Python 程序中使用 HiveContext 时,我发现还需要以下选项:

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

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


我还想指定要使用的特定 Python 版本,这需要另一个选项:

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

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

关于apache-spark - Spark sql 在 yarn 集群模式下抛出 java.lang.OutOfMemoryError 但在 yarn 客户端模式下工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31729172/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com