gpt4 book ai didi

hadoop - 对大量倾斜数据集的 Hive 排序操作

转载 作者:可可西里 更新时间:2023-11-01 14:55:22 31 4
gpt4 key购买 nike

我正在 Hortonworks 2.6.5 上处理一个大小约为 3 TB 的大型数据集,数据集的布局非常简单。

数据的层次结构如下-

-Country
-Warehouse
-Product
-Product Type
-Product Serial Id

我们在上述层次结构中拥有 30 个国家/地区的交易数据,每个国家/地区有 200 多个仓库,单个国家/地区美国贡献了整个数据集的 75% 左右。

问题:

1)对于每个仓库的上述数据集,我们有带有交易日期列(trans_dt)的交易数据,我需要使用Hive(1.1.2版本)对每个仓库内的trans_dt进行升序排序)映射减少。我在国家级别创建了一个分区,然后应用 DISTRIBUTE BY Warehouse SORT BY trans_dt ASC;排序大约需要 8 个小时才能完成,最后 6 个小时用于 Reducer 99% 的阶段。我在这个阶段看到了很多洗牌。

2) 我们对这个组合做了很多分组 - Country,Warehouse,Product,Product Type,Product Serial Id任何优化这个操作的建议都将非常有帮助。

3) 如何处理美国国家的倾斜数据集?

我们正在使用以下配置单元属性。

SET hive.exec.compress.intermediate=true;
SET hive.intermediate.compression.codec=org.apache.hadoop.io.compress.SnappyCodec;
SET hive.intermediate.compression.type=BLOCK;
SET hive.exec.compress.output=true;
SET mapreduce.output.fileoutputformat.compress=true;
SET mapreduce.output.fileoutputformat.compress.codec=org.apache.hadoop.io.compress.SnappyCodec;
SET mapreduce.output.fileoutputformat.compress.type=BLOCK;
SET hive.auto.convert.join=true;
SET hive.auto.convert.join.noconditionaltask=true;
SET hive.auto.convert.join.noconditionaltask.size=10000000;
SET hive.groupby.skewindata=true;
SET hive.optimize.skewjoin.compiletime=true;
SET hive.optimize.skewjoin=true;
SET hive.optimize.bucketmapjoin=true;
SET hive.exec.parallel=true;
SET hive.cbo.enable=true;
SET hive.stats.autogather=true;
SET hive.compute.query.using.stats=true;
SET hive.stats.fetch.column.stats=true;
SET hive.stats.fetch.partition.stats=true;
SET hive.vectorized.execution.enabled=true;
SET hive.vectorized.execution.reduce.enabled=true;
SET hive.optimize.index.filter=true;
SET hive.optimize.ppd=true;
SET hive.mapjoin.smalltable.filesize=25000000;
SET hive.exec.dynamic.partition=true;
SET hive.exec.dynamic.partition.mode=nonstrict;
SET hive.exec.max.dynamic.partitions.pernode=1000;
SET mapreduce.reduce.memory.mb=10240;
SET mapreduce.reduce.java.opts=-Xmx9216m;
SET mapreduce.map.memory.mb=10240;
SET mapreduce.map.java.opts=-Xmx9216m;
SET mapreduce.task.io.sort.mb=1536;
SET hive.optimize.groupby=true;
SET hive.groupby.orderby.position.alias=true;
SET hive.multigroupby.singlereducer=true;
SET hive.merge.mapfiles=true;
SET hive.merge.smallfiles.avgsize=128000000;
SET hive.merge.size.per.task=268435456;
SET hive.map.aggr=true;
SET hive.optimize.distinct.rewrite=true;
SET mapreduce.map.speculative=false;
set hive.fetch.task.conversion = more;
set hive.fetch.task.aggr=true;
set hive.fetch.task.conversion.threshold=1024000000;

最佳答案

对于美国和非美国使用相同的查询但独立处理它们。

Select * from Table where Country = 'US'
UNION
Select * from Table where Country <> 'US'

您可以使用脚本处理它们,在该脚本中一次触发一个国家/地区的查询,从而减少需要在一个实例中处理的数据量。

INSERT INTO TABLE <AggregateTable>
SELECT * FROM <SourceTable>
WHERE Country in ('${hiveconf:ProcessCountry}')

关于hadoop - 对大量倾斜数据集的 Hive 排序操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57310000/

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