对于具有大量 YARN 聚合日志的集群,将它们合并到 Hadoop 归档中以减少小文件数量(从而减少 NameNode 上的压力)可能会有所帮助。此工具提供了一种简单的方法来执行此操作。Hadoop 归档中的聚合日志仍可由作业历史记录服务器和 yarn logs 命令读取。
有关 Hadoop 归档的更多信息,请参阅 Hadoop 归档指南。
usage: mapred archive-logs
-force Force recreating the working directory if
an existing one is found. This should
only be used if you know that another
instance is not currently running
-help Prints this message
-maxEligibleApps <n> The maximum number of eligible apps to
process (default: -1 (all))
-maxTotalLogsSize <megabytes> The maximum total logs size (in
megabytes) required to be eligible
(default: 1024)
-memory <megabytes> The amount of memory (in megabytes) for
each container (default: 1024)
-minNumberLogFiles <n> The minimum number of log files required
to be eligible (default: 20)
-noProxy When specified, all processing will be
done as the user running this command (or
the YARN user if DefaultContainerExecutor
is in use). When not specified, all
processing will be done as the user who
owns that application; if the user
running this command is not allowed to
impersonate that user, it will fail
-verbose Print more details.
该工具仅支持一次在集群上运行一个实例,以防止冲突。它通过检查 HDFS 中 yarn.nodemanager.remote-app-log-dir 下名为 archive-logs-work 的目录是否存在来执行此操作(默认值:/tmp/logs/archive-logs-work)。如果由于某种原因该目录未正确清理,并且该工具拒绝运行,则可以使用 -force 选项强制运行。
-help 选项打印出使用信息。
该工具通过执行以下过程来运行
-minNumberLogFiles 个日志文件-maxTotalLogsSize 兆字节-maxEligibleApps 个,则会丢弃最新的应用程序。它们可以在下次进行处理。-maxEligibleApps 个容器运行,每个容器处理一个应用程序,并使用 -memory 兆字节的内存。每个容器针对单个应用程序运行 hadoop archives 命令,并用生成的存档替换其聚合日志文件。-noProxy 选项使工具可以将所有内容作为当前运行它的用户或(如果使用 DefaultContainerExecutor)YARN 用户进行处理。未指定时,所有处理都将由拥有该应用程序的用户完成;如果运行此命令的用户不允许模拟该用户,则会失败。如果您希望管理员用户在不启用模拟的情况下处理所有聚合,这将非常有用。使用 -noProxy,生成的 HAR 文件将归运行该工具的用户所有,而不是最初拥有日志的用户。
-verbose 选项使工具打印有关其正在执行的操作的更多详细信息。
运行该工具的最终结果是,已处理应用程序的原始聚合日志文件将被包含所有这些日志的 Hadoop 存档替换。