gpt4 book ai didi

hadoop - 了解 GZ 文件的 Hadoop 行为

转载 作者:可可西里 更新时间:2023-11-01 16:59:58 29 4
gpt4 key购买 nike

我的 S3 存储桶中的两个单独文件夹中有一个小的 JSON 文件。我分别在这两个上使用相同的映射器运行了相同的命令。

普通 JSON

$ hadoop jar /home/hadoop/contrib/streaming/hadoop-streaming-1.0.3.jar -Dmapred.reduce.tasks=0 -file ./mapper.py -mapper ./mapper.py -input s3://mybucket/normaltest -output smalltest-output
14/08/28 08:33:53 WARN conf.Configuration: DEPRECATED: hadoop-site.xml found in the classpath. Usage of hadoop-site.xml is deprecated. Instead use core-site.xml, mapred-site.xml and hdfs-site.xml to override properties of core-default.xml, mapred-default.xml and hdfs-default.xml respectively
packageJobJar: [./mapper.py, /mnt/var/lib/hadoop/tmp/hadoop-unjar6225144044327095484/] [] /tmp/streamjob6947060448653690043.jar tmpDir=null
14/08/28 08:33:56 INFO mapred.JobClient: Default number of map tasks: null
14/08/28 08:33:56 INFO mapred.JobClient: Setting default number of map tasks based on cluster size to : 160
14/08/28 08:33:56 INFO mapred.JobClient: Default number of reduce tasks: 0
14/08/28 08:33:56 INFO security.ShellBasedUnixGroupsMapping: add hadoop to shell userGroupsCache
14/08/28 08:33:56 INFO mapred.JobClient: Setting group to hadoop
14/08/28 08:33:56 INFO lzo.GPLNativeCodeLoader: Loaded native gpl library
14/08/28 08:33:56 WARN lzo.LzoCodec: Could not find build properties file with revision hash
14/08/28 08:33:56 INFO lzo.LzoCodec: Successfully loaded & initialized native-lzo library [hadoop-lzo rev UNKNOWN]
14/08/28 08:33:56 WARN snappy.LoadSnappy: Snappy native library is available
14/08/28 08:33:56 INFO snappy.LoadSnappy: Snappy native library loaded
14/08/28 08:33:58 INFO mapred.FileInputFormat: Total input paths to process : 1
14/08/28 08:33:58 INFO streaming.StreamJob: getLocalDirs(): [/mnt/var/lib/hadoop/mapred]
14/08/28 08:33:58 INFO streaming.StreamJob: Running job: job_201408260907_0053
14/08/28 08:33:58 INFO streaming.StreamJob: To kill this job, run:
14/08/28 08:33:58 INFO streaming.StreamJob: /home/hadoop/bin/hadoop job -Dmapred.job.tracker=10.165.13.124:9001 -kill job_201408260907_0053
14/08/28 08:33:58 INFO streaming.StreamJob: Tracking URL: http://ip-10-165-13-124.ec2.internal:9100/jobdetails.jsp?jobid=job_201408260907_0053
14/08/28 08:33:59 INFO streaming.StreamJob: map 0% reduce 0%
14/08/28 08:34:23 INFO streaming.StreamJob: map 1% reduce 0%
14/08/28 08:34:26 INFO streaming.StreamJob: map 2% reduce 0%
14/08/28 08:34:29 INFO streaming.StreamJob: map 9% reduce 0%
14/08/28 08:34:32 INFO streaming.StreamJob: map 45% reduce 0%
14/08/28 08:34:35 INFO streaming.StreamJob: map 56% reduce 0%
14/08/28 08:34:36 INFO streaming.StreamJob: map 57% reduce 0%
14/08/28 08:34:38 INFO streaming.StreamJob: map 84% reduce 0%
14/08/28 08:34:39 INFO streaming.StreamJob: map 85% reduce 0%
14/08/28 08:34:41 INFO streaming.StreamJob: map 99% reduce 0%
14/08/28 08:34:44 INFO streaming.StreamJob: map 100% reduce 0%
14/08/28 08:34:50 INFO streaming.StreamJob: map 100% reduce 100%
14/08/28 08:34:50 INFO streaming.StreamJob: Job complete: job_201408260907_0053
14/08/28 08:34:50 INFO streaming.StreamJob: Output: smalltest-output

smalltest-output 中,我得到了几个包含部分已处理 JSON 的小文件。

GZIP 压缩的 JSON

$ hadoop jar /home/hadoop/contrib/streaming/hadoop-streaming-1.0.3.jar -Dmapred.reduce.tasks=0 -file ./mapper.py -mapper ./mapper.py -input s3://weblablatency/gztest -output smalltest-output
14/08/28 08:39:45 WARN conf.Configuration: DEPRECATED: hadoop-site.xml found in the classpath. Usage of hadoop-site.xml is deprecated. Instead use core-site.xml, mapred-site.xml and hdfs-site.xml to override properties of core-default.xml, mapred-default.xml and hdfs-default.xml respectively
packageJobJar: [./mapper.py, /mnt/var/lib/hadoop/tmp/hadoop-unjar2539293594337011579/] [] /tmp/streamjob301144784484156113.jar tmpDir=null
14/08/28 08:39:48 INFO mapred.JobClient: Default number of map tasks: null
14/08/28 08:39:48 INFO mapred.JobClient: Setting default number of map tasks based on cluster size to : 160
14/08/28 08:39:48 INFO mapred.JobClient: Default number of reduce tasks: 0
14/08/28 08:39:48 INFO security.ShellBasedUnixGroupsMapping: add hadoop to shell userGroupsCache
14/08/28 08:39:48 INFO mapred.JobClient: Setting group to hadoop
14/08/28 08:39:48 INFO lzo.GPLNativeCodeLoader: Loaded native gpl library
14/08/28 08:39:48 WARN lzo.LzoCodec: Could not find build properties file with revision hash
14/08/28 08:39:48 INFO lzo.LzoCodec: Successfully loaded & initialized native-lzo library [hadoop-lzo rev UNKNOWN]
14/08/28 08:39:48 WARN snappy.LoadSnappy: Snappy native library is available
14/08/28 08:39:48 INFO snappy.LoadSnappy: Snappy native library loaded
14/08/28 08:39:50 INFO mapred.FileInputFormat: Total input paths to process : 1
14/08/28 08:39:51 INFO streaming.StreamJob: getLocalDirs(): [/mnt/var/lib/hadoop/mapred]
14/08/28 08:39:51 INFO streaming.StreamJob: Running job: job_201408260907_0055
14/08/28 08:39:51 INFO streaming.StreamJob: To kill this job, run:
14/08/28 08:39:51 INFO streaming.StreamJob: /home/hadoop/bin/hadoop job -Dmapred.job.tracker=10.165.13.124:9001 -kill job_201408260907_0055
14/08/28 08:39:51 INFO streaming.StreamJob: Tracking URL: http://ip-10-165-13-124.ec2.internal:9100/jobdetails.jsp?jobid=job_201408260907_0055
14/08/28 08:39:52 INFO streaming.StreamJob: map 0% reduce 0%
14/08/28 08:40:20 INFO streaming.StreamJob: map 100% reduce 0%
14/08/28 08:40:26 INFO streaming.StreamJob: map 100% reduce 100%
14/08/28 08:40:26 INFO streaming.StreamJob: Job complete: job_201408260907_0055

在 smalltest-output 中,我得到一个正确解析的文件,但作为单个文件。

为什么会出现这种差异以及发生了什么?我的工作在 gz 案例中没有正确分配吗?

在我的实际用例中,我需要处理 ~2000 gz 文件,总计约 4GB 未压缩;每 4 小时一次。所以我无法承受压缩带来的任何性能问题。

最佳答案

Gzip 不可拆分。你会发现无数的文章和问题都在谈论这个问题,所以我不会详细介绍。

您的选择是:

  • 不要使用 Gzip(不要压缩或使用其他可拆分压缩格式)
  • 使用 hack 使 GZip 可拆分,例如 https://github.com/nielsbasjes/splittablegzip .每个映射器仍然必须从头开始读取文件,因此这是一种权衡。阅读文档以了解更多信息。

这取决于你做什么,但对于大多数处理 4GB 的数据来说不算什么。我会确保我的用例确实需要像 Hadoop 这样的大象。它具有可扩展性,但复杂,工作起来很痛苦,而且对于小数据集来说通常很慢。

关于hadoop - 了解 GZ 文件的 Hadoop 行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25544899/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com