Number of dynamic partitions exceeded hive.exec.max.dynamic.partitions.pernode

本文讨论了在使用Hive进行大数据处理时遇到动态分区数超过限制的问题,并提供了通过调整配置参数来解决该问题的方法。

动态分区数太大的问题:[Fatal Error] Operator FS_2 (id=2): Number of dynamic partitions exceeded hive.exec.max.dynamic.partitions.pernode.


hive> insert into table sogouq_test partition(query_time) select user_id,query_word,query_order,click_order,url,query_time from sogouq_test_tmp;
Total MapReduce jobs = 3
Launching Job 1 out of 3
Number of reduce tasks is set to 0 since there's no reduce operator
Starting Job = job_1409113942738_0026, Tracking URL = http://centos1:8088/proxy/application_1409113942738_0026/
Kill Command = /home/hadoop-2.2/bin/hadoop job  -kill job_1409113942738_0026
Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 0
2014-08-27 03:55:16,868 Stage-1 map = 0%,  reduce = 0%
[Fatal Error] Operator FS_2 (id=2): Number of dynamic partitions exceeded hive.exec.max.dynamic.partitions.pernode.
Sample of 100 partitions created under hdfs://centos1:8020/hive/scratchdir/hive_2014-08-27_03-55-09_118_348369539322185503-1/_tmp.-ext-10002:
        .../query_time=20111230000005
        .../query_time=20111230000007
        .../query_time=20111230000008
        .../query_time=20111230000009
        .../query_time=20111230000010
        .../query_time=20111230000011


查看最大分区数:

hive> set hive.exec.max.dynamic.partitions.pernode;
hive.exec.max.dynamic.partitions.pernode=100

将该参数设置的大一点,问题即解决。

Hive 中,`SET hive.exec.max.dynamic.partitions.pernode` 和 `hive.exec.max.dynamic.partitions` 这两个参数用于控制动态分区的生成数量,分别表示每个节点允许创建的最大动态分区数和整个作业允许创建的最大动态分区数。这些参数的默认值通常较低(如 100),在处理大规模数据时容易触发错误提示:“The maximum number of dynamic partitions is controlled by hive.exec.max.dynamic.partitions and hive.exec.max.dynamic.partitions.pernode. Maximum was set to: 100” [^1]。 为了正确设置这些参数,应在执行 Hive SQL 语句之前,在 Hive Shell 或 Hive 查询上下文中使用 `SET` 命令进行配置。例如: ```sql SET hive.exec.dynamic.partition = true; SET hive.exec.dynamic.partition.mode = nonstrict; SET hive.exec.max.dynamic.partitions.pernode = 100000; SET hive.exec.max.dynamic.partitions = 100000; SET hive.exec.max.created.files = 100000; ``` 上述配置确保 Hive 允许在每个节点上最多生成 100000 个动态分区,整个作业最多生成 100000 个动态分区,并允许创建最多 100000 个文件。这些设置应放在插入动态分区数据的 SQL 脚本或 Hive Shell 会话的最开始部分,以确保在执行插入操作前生效 [^1]。 如果使用 Spark 或 Flink 等外部引擎向 Hive 写入数据,并希望这些参数生效,则需要通过对应的配置接口进行设置。例如,在 Spark Submit 中应使用以下方式设置参数: ```bash spark-submit \ --conf spark.hadoop.hive.exec.max.dynamic.partitions=10000 \ --conf spark.hadoop.hive.exec.max.dynamic.partitions.pernode=10000 \ ... ``` 在 Flink 中,可以通过 `table.exec.hive.max.dynamic.partitions` 等参数进行类似配置。这种方式确保 Hive 的动态分区限制在外部执行引擎中也被正确识别 [^5]。 ### 相关问题 1. Hive 动态分区模式 strict 和 nonstrict 有何区别? 2. Spark 写入 Hive 分区表时需要注意哪些配置参数? 3. Hive 插入分区表时如何避免因空数据导致写入失败? 4. Hive 动态分区操作中为何会出现元数据与 HDFS 数据不一致的问题? 5. 如何在 Flink 中配置 Hive 分区表的提交策略?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值