【问题标题】:Uneven distribution of data to reducer数据不均匀分布到reducer
【发布时间】:2015-01-18 08:27:27
【问题描述】:

我有一个看起来无害的 Hive 查询,它从一个表中获取一些数据以覆盖到另一个表中。源表和目标表都是分区的。目标表也是集群的。

此查询生成 4 个 MR 作业,最后一个作业在缩减阶段总是花费异常大量的时间。我尝试增加减速器的数量,但这并没有帮助。深入研究后,我注意到指定的 130 个 reducer 中的 1 个(最初是默认的 26 个 reducer 中的 1 个)似乎总是比其他的接收更多的数据。我进一步尝试在分布良好的列上使用分发子句,但这也无济于事。

有没有一种方法可以找出大多数数据似乎都流向一个 reducer 的原因是什么?或者,有关如何控制此数据量的任何建议都会非常有帮助。

我的代码(表名和列名已更改)。 目标在列 l 和 m 上进行分区 目的地由 user_id 聚类

set hive.enforce.bucketing = true;
set mapred.reduce.tasks=130;

insert overwrite table dest_table
select
  coalesce(event_guid, "<UNKNOWN>") event_guid,
  coalesce(a, "<UNKNOWN>"),
  coalesce(b, "<UNKNOWN>"),
  coalesce(user_id, "<UNKNOWN>"),
  coalesce(c, "<UNKNOWN>"),
  coalesce(d, "<UNKNOWN>"),
  coalesce(e, "<UNKNOWN>"),
  coalesce(f, "<UNKNOWN>"),
  coalesce(g, "<UNKNOWN>"),
  coalesce(h, "<UNKNOWN>"),
  coalesce(i, "<UNKNOWN>"),
  coalesce(j, "<UNKNOWN>"),
  coalesce(k, "<UNKNOWN>"),
  coalesce(l, "<UNKNOWN>"),
  coalesce(m, "<UNKNOWN>"),
  coalesce(n, "<UNKNOWN>"),
  coalesce(o, "<UNKNOWN>"),
  coalesce(p, "<UNKNOWN>"),
  coalesce(q, "<UNKNOWN>"),
  coalesce(r, "<UNKNOWN>"),
  coalesce(to_date(from_utc_timestamp(s, "PST")), "0000-00-00"),
  coalesce(cast(from_utc_timestamp(s, "PST") as string), '0000-00-00 00:00:00'),
  coalesce(s, '0000-00-00 00:00:00'),
  coalesce(t, '0000-00-00 00:00:00'),
  coalesce(u, '0000-00-00 00:00:00'),
  coalesce(cast(from_utc_timestamp(t, "PST") as string), '0000-00-00 00:00:00'),
  coalesce(cast(from_utc_timestamp(u, "PST") as string), '0000-00-00 00:00:00'),
  coalesce(to_date(from_utc_timestamp(u, "PST")), "0000-00-00"),
  coalesce(v, "<UNKNOWN>"),
  coalesce(w, "<UNKNOWN>"),
  coalesce(x, "<UNKNOWN>")
from
  source raw
where v is not null and w is not null and x is not null
distribute by event_guid
;

【问题讨论】:

    标签: hadoop mapreduce hive reduce


    【解决方案1】:

    这只是一个建议,但您可以在 hive 中使用 TRANSFORM 或 MAP/REDUCE 关键字尝试自己的映射器和化简器脚本来控制数据。例如选择键作为提供均匀分布的列(这是您尝试使用分发来实现的目标) 确实可能需要做一些 HQL 分析。在 event_guid 上运行一个分组,count(*)。计数是否均匀分布?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-04-04
      • 2018-02-06
      • 2011-12-05
      • 1970-01-01
      • 2011-04-04
      • 2011-08-07
      相关资源
      最近更新 更多