admin管理员组文章数量:1593428
1.背景
这里介绍的日志清理是standlone模式下的,其它的我没有研究过。
提交到spark的程序,worker会启动有多个executor,在${SPARK_HOME}/work下,可以看到有很多app-*文件夹,这些文件夹放的是程序运行时的日志、jar包等。如果不清理的话,这些文件夹肯定是越来越多的,时间长了也会占用较多的磁盘空间。下
2.清理方法
2.1清理运行完成后的文件夹
修改${SPARK_HOME}/conf/目录下的spark-env.sh。
vim ${SPARK_HOME}/conf/spark-env.sh
#加入以下参数
export SPARK_WORKER_OPTS="-Dspark.worker.cleanup.enabled=true -Dspark.worker.cleanup.interval=1800 -Dspark.worker.cleanup.appDataTtl=86400"
参数解析
- Dspark.worker.cleanup.enabled
这个参数是开启worker文件夹清理。 - Dspark.worker.cleanup.interval
这个参数是设置清理文件夹的检查时间间隔,这里是30分钟 - Dspark.worker.cleanup.appDataTtl=86400
这个参数是设置程序停止后86400s,即1天后删除
2.2 运行日志设置
进程在运行过程中,在app*目录的${id}/logs/目录下,会生成很多的info.log。可以调整${SPARK_HOME}/conf/spark-defaults.conf的以下参数,然后重启spark。
vim ${SPARK_HOME}/conf/spark-defaults.conf
#加入以下参数
spark.executor.logs.rolling.maxRetainedFiles 30
spark.executor.logs.rolling.enableCompression true
spark.executor.logs.rolling.strategy time
spark.executor.logs.rolling.time.interval daily
参数解析:
- spark.executor.logs.rolling.maxRetainedFiles
这个参数表示最大保存的日志文件个数 - spark.executor.logs.rolling.enableCompression
这个参数表示日志是否开启压缩 - spark.executor.logs.rolling.strategy
这个参数表示日志的检查策略,有time和size。这里用time - spark.executor.logs.rolling.time.interval
这个参数表示检查的时间间隔,有daily, hourly, minutely,seconds。这里用daily。
更多参数请参考这里
注:以上2.2中的参数亲测目前不生效。后面我在看下是啥原因。
版权声明:本文标题:spark日志清理 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1726093193a1055192.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论