【问题标题】:Configuring large Hive import job配置大型 Hive 导入作业
【发布时间】:2019-02-15 03:04:54
【问题描述】:

我是一个新手,正在尝试获取一个大型(1.25 TB 未压缩)hdfs 文件并将其放入 Hive 托管表中。它已经在具有任意分区的 csv 格式(来自 sqoop)的 HDFS 上,我将其放入更有条理的格式以进行查询和加入。我在使用 Tez 的 HDP 3.0 上。这是我的hql

USE MYDB;

DROP TABLE IF EXISTS new_table;

CREATE TABLE IF NOT EXISTS new_table (
 svcpt_id VARCHAR(20),
 usage_value FLOAT,
 read_time SMALLINT)
PARTITIONED BY (read_date INT)
CLUSTERED BY (svcpt_id) INTO 9600 BUCKETS
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS ORC
TBLPROPERTIES("orc.compress"="snappy");

SET hive.exec.dynamic.partition=true;
SET hive.exec.dynamic.partition.mode=nonstrict;
SET hive.exec.max.dynamic.partitions.pernode=2000;
SET hive.exec.max.dynamic.partitions=10000;
SET hive.vectorized.execution.enabled = true;
SET hive.vectorized.execution.reduce.enabled = true;
SET hive.enforce.bucketing = true;
SET mapred.reduce.tasks = 10000;

INSERT OVERWRITE TABLE new_table
PARTITION (read_date)
SELECT svcpt_id, usage, read_time, read_date
FROM raw_table;

Tez 的设置方式是(根据我最近的失败):

--------------------------------------------------------------------------------
VERTICES      STATUS  TOTAL  COMPLETED  RUNNING  PENDING  FAILED  KILLED
--------------------------------------------------------------------------------
Map 1      SUCCEEDED   1043       1043        0        0       0       0
Reducer 2    RUNNING   9600        735       19     8846       0       0
Reducer 3     INITED  10000          0        0    10000       0       0
--------------------------------------------------------------------------------
VERTICES: 01/03  [==>>------------------------] 8%    ELAPSED TIME: 45152.59 s
--------------------------------------------------------------------------------

我已经为此工作了一段时间。起初我无法让第一个 map 1 顶点运行,所以我添加了存储桶。 96 个存储桶让第一个映射器运行,但 reducer 2 失败,原因是磁盘空间问题没有意义。然后我将存储桶的数量增加到 9600 并将任务减少到 10000 并且reduce 2 顶点开始运行,尽管速度很慢。今天早上我发现它出错了,因为我的namenode由于垃圾收集器的java堆空间错误而关闭。

有人对我有什么指导意见吗?对于减少任务的数量、存储桶的数量以及下面显示的所有配置,我觉得我在黑暗中射击。

hive.tez.container.size = 5120MB
hive.exec.reducers.bytes.per.reducer = 1GB
hive.exec.max.dynamic.partitions = 5000
hive.optimize.sort.dynamic.partition = FALSE
hive.vectorized.execution.enabled = TRUE
hive.vectorized.execution.reduce.enabled = TRUE
yarn.scheduler.minimum-allocation-mb = 2G
yarn.scheduler.maximum-allocation-mb = 8G
mapred.min.split.size=?
mapred.max.split.size=?
hive.input.format=?
mapred.min.split.size=?

尚未设置 LLAP

我的集群有 4 个节点、32 个内核和 120 GB 内存。我没有使用超过 1/3 的集群存储空间。

【问题讨论】:

  • 增加reducer的数量/减少bytes.per.reducer。但是集群很小,只有少量的 reducer 会同时运行,其他的会挂起
  • 非常感谢您的评论。有没有一个公式可以用来弄清楚如何设置这些?有资源吗?每次迭代大约需要 1.5 小时,所以我可能很难测试出不同的值。
  • 由于分桶,您有 9600 个减速器。在这种情况下,它等于桶的数量。尝试删除存储桶并首先设置 hive.enforce.bucketing =false。然后 hive.exec.reducers.bytes.per.reducer 将起作用。看到这个:stackoverflow.com/a/42842117/2700344stackoverflow.com/a/51061613/2700344
  • 感谢@leftjoin,我的意思是我想要分桶-我认为他们会让我的查询和连接更快,因为我通常会在svcpt_id 上查询,但我不知道如何设置桶数。有什么想法吗?每个桶的典型尺寸?
  • 3-5 M 行恕我直言。因为这样的数字每一个容器都很好。但这取决于太多的因素。文件太多也不好。顺便说一句,ORC 有索引和布隆过滤器,在你的情况下它可以代替存储桶吗?

标签: hadoop hive hortonworks-data-platform apache-tez


【解决方案1】:
SET hive.execution.engine = tez;
SET hive.vectorized.execution.enabled = false;
SET hive.vectorized.execution.reduce.enabled = false;
SET hive.enforce.bucketing = true;
SET hive.exec.dynamic.partition.mode = nonstrict;
SET hive.stats.autogather = true;
SET hive.exec.parallel = true;
SET hive.exec.parallel.thread.number = 60;
SET mapreduce.job.skiprecords = true;
SET mapreduce.map.maxattempts =10;
SET mapreduce.reduce.maxattempts =10;
SET mapreduce.map.skip.maxrecords = 300;
SET mapreduce.task.skip.start.attempts = 1;
SET mapreduce.output.fileoutputformat.compress = false;
SET mapreduce.job.reduces = 1000;

你可以试试上面的一些设置!

【讨论】:

  • 这个设置将有助于 SET mapreduce.job.reduces = 1000;
  • 感谢这些! # 个桶呢?有什么公式可以用吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-12
相关资源
最近更新 更多