配置 Hadoop 日志记录以避免日志文件过多

发布于 2024-08-28 20:04:52 字数 467 浏览 2 评论 0原文

我遇到了 Hadoop 在 $HADOOP_LOG_DIR/userlogs 中生成太多日志文件的问题(Ext3 文件系统仅允许 32000 个子目录),这看起来与这个问题中的问题相同: Hadoop MapReduce 中的错误

我的问题是:有谁知道如何配置 Hadoop 来滚动日志目录或以其他方式防止这种情况发生?我试图避免只设置“mapred.userlog.retain.hours”和/或“mapred.userlog.limit.kb”属性,因为我想实际保留日志文件。

我也希望在 log4j.properties 中配置它,但是查看 Hadoop 0.20.2 源代码,它直接写入日志文件而不是实际使用 log4j。也许我不明白它是如何完全使用log4j的。

任何建议或澄清将不胜感激。

I'm having a problem with Hadoop producing too many log files in $HADOOP_LOG_DIR/userlogs (the Ext3 filesystem allows only 32000 subdirectories) which looks like the same problem in this question: Error in Hadoop MapReduce

My question is: does anyone know how to configure Hadoop to roll the log dir or otherwise prevent this? I'm trying to avoid just setting the "mapred.userlog.retain.hours" and/or "mapred.userlog.limit.kb" properties because I want to actually keep the log files.

I was also hoping to configure this in log4j.properties, but looking at the Hadoop 0.20.2 source, it writes directly to logfiles instead of actually using log4j. Perhaps I don't understand how it's using log4j fully.

Any suggestions or clarifications would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

一花一树开 2024-09-04 20:04:52

不幸的是,没有一种可配置的方法来防止这种情况发生。作业的每个任务都会在history/userlogs 中获得一个目录,该目录将保存stdout、stderr 和syslog 任务日志输出文件。保留时间将有助于防止累积太多,但您必须编写一个好的日志轮换工具来自动打包它们。

当我们写入 NFS 挂载时,我们也遇到了这个问题,因为所有节点都会共享相同的 History/userlogs 目录。这意味着一项包含 30,000 个任务的作业足以破坏 FS。当您的集群实际开始处理大量数据时,本地日志记录确实是一种可行的方法。

如果您已经在本地进行日志记录,并且仍然设法在不到一周的时间内在一台计算机上处​​理 30,000 多个任务,那么您可能创建了太多小文件,导致每个作业生成太多映射器。

Unfortunately, there isn't a configurable way to prevent that. Every task for a job gets one directory in history/userlogs, which will hold the stdout, stderr, and syslog task log output files. The retain hours will help keep too many of those from accumulating, but you'd have to write a good log rotation tool to auto-tar them.

We had this problem too when we were writing to an NFS mount, because all nodes would share the same history/userlogs directory. This means one job with 30,000 tasks would be enough to break the FS. Logging locally is really the way to go when your cluster actually starts processing a lot of data.

If you are already logging locally and still manage to process 30,000+ tasks on one machine in less than a week, then you are probably creating too many small files, causing too many mappers to spawn for each job.

分开我的手 2024-09-04 20:04:52

我也有同样的问题。在启动 Hadoop 之前设置环境变量“HADOOP_ROOT_LOGGER=WARN,console”。

export HADOOP_ROOT_LOGGER="WARN,console"
hadoop jar start.jar

I had this same problem. Set the environment variable "HADOOP_ROOT_LOGGER=WARN,console" before starting Hadoop.

export HADOOP_ROOT_LOGGER="WARN,console"
hadoop jar start.jar
信仰 2024-09-04 20:04:52

配置 hadoop 以使用 log4j 并

log4j.appender.FILE_AP1.MaxFileSize=100MB
log4j.appender.FILE_AP1.MaxBackupIndex=10

按照 此 wiki 页面 中所述的设置不起作用?

查看 LogLevel源代码,看起来hadoop使用commons日志记录,默认情况下它会尝试使用log4j,或者如果log4j不在类路径上,则使用jdk logger。

顺便说一句,可以在运行时更改日志级别,请查看 命令手册

Configuring hadoop to use log4j and setting

log4j.appender.FILE_AP1.MaxFileSize=100MB
log4j.appender.FILE_AP1.MaxBackupIndex=10

like described on this wiki page doesn't work?

Looking at the LogLevel source code, seems like hadoop uses commons logging, and it'll try to use log4j by default, or jdk logger if log4j is not on the classpath.

Btw, it's possible to change log levels at runtime, take a look at the commands manual.

書生途 2024-09-04 20:04:52

根据文档,Hadoop 使用 log4j 进行日志记录。也许您找错地方了......

According to the documentation, Hadoop uses log4j for logging. Maybe you are looking in the wrong place ...

流年已逝 2024-09-04 20:04:52

我也遇到了同样的问题...... Hive产生大量日志,当磁盘节点已满时,无法启动更多容器。在 Yarn 中,当前没有禁用日志记录的选项。系统日志文件是一个特别巨大的文件,在我们的例子中,它会在几分钟内生成 GB 的日志。

在“yarn-site.xml”中将属性yarn.nodemanager.log.retain-seconds 配置为较小的值并没有帮助。将“yarn.nodemanager.log-dirs”设置为“file:///dev/null”是不可能的,因为需要一个目录。删除写入权(chmod -r /logs)也不起作用。

一种解决方案可能是“空黑洞”目录。检查这里:
https://unix.stackexchange.com/ questions/9332/how-can-i-create-a-dev-null-like-blackhole-directory

对我们有用的另一个解决方案是在运行作业之前禁用日志。例如,在 Hive 中,通过以下几行启动脚本是有效的:

set yarn.app.mapreduce.am.log.level=OFF;
set mapreduce.map.log.level=OFF;
set mapreduce.reduce.log.level=OFF;

I also ran in the same problem.... Hive produce a lot of logs, and when the disk node is full, no more containers can be launched. In Yarn, there is currently no option to disable logging. One file particularly huge is the syslog file, generating GBs of logs in few minutes in our case.

Configuring in "yarn-site.xml" the property yarn.nodemanager.log.retain-seconds to a small value does not help. Setting "yarn.nodemanager.log-dirs" to "file:///dev/null" is not possible because a directory is needed. Removing the writing ritght (chmod -r /logs) did not work either.

One solution could be to a "null blackhole" directory. Check here:
https://unix.stackexchange.com/questions/9332/how-can-i-create-a-dev-null-like-blackhole-directory

Another solution working for us is to disable the log before running the jobs. For instance, in Hive, starting the script by the following lines is working:

set yarn.app.mapreduce.am.log.level=OFF;
set mapreduce.map.log.level=OFF;
set mapreduce.reduce.log.level=OFF;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文