【问题标题】:wholeTextFiles Method is failing with ExitCode 52 java.lang.OutOfMemoryErrorwholeTextFiles 方法因 ExitCode 52 java.lang.OutOfMemoryError 而失败
【发布时间】:2019-06-19 18:31:00
【问题描述】:

我有 HDFS 目录,其中有 13.2 GB 和 4 个文件。我正在尝试使用 spark 中的wholeTextFile 方法读取所有文件,但我有一些问题

这是我的代码。

val path = "/tmp/cnt/warehouse/"
val whole = sc.wholeTextFiles("path",32)
val data = whole.map(r => (r._1,r._2.split("\r\n")))
val x = file.flatMap(r => r._1)
x.take(1000).foreach(println)

下面是火花提交。

spark2-submit \
--class SparkTest \
--master yarn \
--deploy-mode cluster \
--num-executors 32 \
--executor-memory 15G \
--driver-memory 25G \
--conf spark.yarn.maxAppAttempts=1 \
--conf spark.port.maxRetries=100 \
--conf spark.kryoserializer.buffer.max=1g \
--conf spark.yarn.queue=xyz \
SparkTest-1.0-SNAPSHOT.jar
  1. 即使我给最小分区 32,它只存储在 4 个分区中。
  2. 我的 spark 提交是否正确?

下面的错误

Job aborted due to stage failure: Task 0 in stage 32.0 failed 4 times, most recent failure: Lost task 0.3 in stage 32.0 (TID 113, , executor 37): ExecutorLostFailure (executor 37 exited caused by one of the running tasks) Reason: Container from a bad node: container_e599_1560551438641_35180_01_000057 on host: . Exit status: 52. Diagnostics: Exception from container-launch.
Container id: container_e599_1560551438641_35180_01_000057
Exit code: 52
Stack trace: ExitCodeException exitCode=52: 
    at org.apache.hadoop.util.Shell.runCommand(Shell.java:604)
    at org.apache.hadoop.util.Shell.run(Shell.java:507)
    at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:789)
    at org.apache.hadoop.yarn.server.nodemanager.LinuxContainerExecutor.__launchContainer__(LinuxContainerExecutor.java:399)
    at org.apache.hadoop.yarn.server.nodemanager.LinuxContainerExecutor.launchContainer(LinuxContainerExecutor.java)
    at org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:302)
    at org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:82)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)



Container exited with a non-zero exit code 52
.
Driver stacktrace:

【问题讨论】:

  • Spark textFile vs wholeTextFiles 的可能重复项。这应该可以解释为什么 wholeTextFiles 在文件很大时会失败,以及为什么你只能得到 4 个分区。如果可能,请尝试使用textFile
  • 您能否向我们提供您在从 HDFS 读取文件时遇到的错误
  • 错误信息被添加到问题@Nikk

标签: scala apache-spark


【解决方案1】:
  1. 即使我给最小分区 32,它存储在 4 个分区中 仅限。

您可以参考以下链接

Spark Creates Less Partitions Then minPartitions Argument on WholeTextFiles

  1. 我的 spark 提交是否正确?

语法正确,但您传递的值超出了它的需要。我的意思是您将 32 * 15 = 480 GB 给 Executors + 25 GB 给驱动程序只是为了处理 13 GB 数据? 给予更多的执行者和更多的内存并不能产生有效的结果。有时它会导致开销以及由于缺乏资源而导致失败
错误还显示您正在使用的资源存在问题。 对于仅处理 13 GB 的数据,您应该使用如下配置(不完全是,您必须计算):

执行者 #6 核心#5 执行器内存 5 GB 驱动程序内存 2 GB

更多详情及计算可参考以下链接:

How to tune spark executor number, cores and executor memory?

注意:Driver 不需要比 Executor 更多的内存,所以 Driver 在大多数情况下,内存应该小于或等于 Executor 内存。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-21
    • 2017-06-27
    • 2018-06-04
    • 2022-01-06
    • 2018-08-18
    • 2015-10-30
    • 2015-08-26
    • 2014-07-11
    相关资源
    最近更新 更多