hive优化:执行sql报错 org.apache.hadoop.hive.ql.exec.mr.MapredLocalTask

前言:

dolphinscheduer调度器执行hive sql报错

报错信息:

[ERROR] 2023-12-05 15:49:49.165 +0800 - execute sql error: Error while processing statement: FAILED: Execution Error, return code 3 from org.apache.hadoop.hive.ql.exec.mr.MapredLocalTask
[ERROR] 2023-12-05 15:49:49.165 +0800 - sql task error
java.sql.SQLException: Error while processing statement: FAILED: Execution Error, return code 3 from org.apache.hadoop.hive.ql.exec.mr.MapredLocalTask
    at org.apache.hive.jdbc.HiveStatement.waitForOperationToComplete(HiveStatement.java:385)
    at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:254)
    at org.apache.hive.jdbc.HiveStatement.executeUpdate(HiveStatement.java:490)
    at org.apache.hive.jdbc.HivePreparedStatement.executeUpdate(HivePreparedStatement.java:122)
    at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)

查看详细报错日志:

yarn logs -applicationId application_1708916729114_4410 | less
yarn logs -applicationId application_1708916729114_4410 | grep Error

日志内容:

Caused by: org.apache.hadoop.hive.ql.metadata.HiveFatalException: [Error 20004]: Fatal error occurred when node tried to create too many dynamic partitions. The maximu
m number of dynamic partitions is controlled by hive.exec.max.dynamic.partitions and hive.exec.max.dynamic.partitions.pernode. Maximum was set to 100 partitions per no
de, number of dynamic partitions on this node: 101

sql生成动态分区数超过限制。

解决方式:

方式一:

执行sql查询语句

#sql脚本前面增加设置
set hive.auto.convert.join= false;
set hive.map.aggr=false;

方式二:

插入sql时分区数量过大

#修改hive配置,将创建动态分区数设置成200
hive.exec.max.dynamic.partitions.pernode = 200;

 其他方式解决:

Hive SQL内存溢出通常与执行查询时配置的内存资源有关。可以尝试以下步骤来解决:
1、调整Hive的执行参数,比如增大mapreduce.map.memory.mb和mapreduce.reduce.memory.mb以增加单个任务的内存。
2、增加hive.exec.dynamic.partition.mode为nonstrict模式,允许动态分区时减少内存使用。
3、分割大查询为小查询,避免一次性处理大量数据。
4、使用Hive的hive.tez.container.size和hive.tez.java.opts调整Tez任务的内存设置。
5、优化查询语句,避免全表扫描和大连接操作。

参考链接:

https://blog.csdn.net/weixin_48874360/article/details/125508644

https://blog.csdn.net/weixin_34290631/article/details/92335352

posted @ 2023-12-06 09:50  所向披靡zz  阅读(226)  评论(0编辑  收藏  举报