背景:
对单月日志进行分析时(120G左右),生成结果csv文件时
.coalesce(1)
.write
.mode(SaveMode.Overwrite)
.format("com.databricks.spark.csv")
.option("header", "true")
.save("periodowntop10.csv")
**coalesce函数为控制结果文件个数为1 因为有多少个partition 就会在指定目录下生成对应个数的csv小文件
在集群运行时
会产生
Unable to acquire xxx bytes of memor这个错误
之前在估算数据源大小和产生数据大小时 最后生成的csv大概在10MB左右
查看运行参数设置
--master yarn --deploy-mode cluster --executor-memory 6g --num-executors 3 --executor-cores 3 --driver-memory 2g --conf spark.default.parallelism=300
查看stage对应信息 发现问题产生在写入csv文件时,读取日志数据源时可以正确读取
所以没必要像大多数网上给出的答案直接粗暴加大executor内存
因为在写的时候在尽量避免shuffle的前提下,所以选择了coalesce
其实问题在.coalesce(1)上
根据