hive经典错误 Error: org.apache.hive.service.cli.HiveSQLException:return code 2

hive 插入数据错误 但是查询能够正常查询

0: jdbc:hive2://t1:10000> INSERT INTO TABLE ADS_APL_NRT_DEMO
. . . . . . . . . . . . > SELECT 
. . . . . . . . . . . . > first_dt    as    dt,
. . . . . . . . . . . . > count(1)    as    dnu_cnts,
. . . . . . . . . . . . > datediff('2020-01-16',first_dt) as nrt_days,
. . . . . . . . . . . . > count(if(last_dt='2020-01-16',1,null)) as nrt_users
. . . . . . . . . . . . > FROM DEMO_DWS_APL_HSU_REC
. . . . . . . . . . . . > GROUP BY first_dt
. . . . . . . . . . . . > ;
Error: org.apache.hive.service.cli.HiveSQLException: Error while processing statement: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
        at org.apache.hive.service.cli.operation.Operation.toSQLException(Operation.java:380)
        at org.apache.hive.service.cli.operation.SQLOperation.runQuery(SQLOperation.java:257)
        at org.apache.hive.service.cli.operation.SQLOperation.access$800(SQLOperation.java:91)
        at org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork$1.run(SQLOperation.java:348)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1844)
        at org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork.run(SQLOperation.java:362)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748) (state=08S01,code=2)

尝试解决方案一 发现正如网上所说 使用的数据有一列(last_dt)为null 修正后未恢复正常

select * from DEMO_DWS_APL_HSU;
+----------------------+------------------------+----------------------------+---------------------------+
| demo_dws_apl_hsu.dt  | demo_dws_apl_hsu.guid  | demo_dws_apl_hsu.first_dt  | demo_dws_apl_hsu.last_dt  |
+----------------------+------------------------+----------------------------+---------------------------+
| a                    | 2020-01-12             | 2020-01-16                 | NULL                      |
| b                    | 2020-01-12             | 2020-01-15                 | NULL                      |
| c                    | 2020-01-12             | 2020-01-16                 | NULL                      |
| d                    | 2020-01-12             | 2020-01-13                 | NULL                      |
| e                    | 2020-01-12             | 2020-01-16                 | NULL                      |
| f                    | 2020-01-12             | 2020-01-16                 | NULL                      |
| g                    | 2020-01-13             | 2020-01-14                 | NULL                      |
| h                    | 2020-01-13             | 2020-01-15                 | NULL                      |
| j                    | 2020-01-13             | 2020-01-16                 | NULL                      |
| k                    | 2020-01-13             | 2020-01-14                 | NULL                      |
| m                    | 2020-01-13             | 2020-01-15                 | NULL                      |
| n                    | 2020-01-13             | 2020-01-14                 | NULL                      |
| o                    | 2020-01-14             | 2020-01-16                 | NULL                      |
| p                    | 2020-01-14             | 2020-01-14                 | NULL                      |
| q                    | 2020-01-14             | 2020-01-14                 | NULL                      |
| r                    | 2020-01-14             | 2020-01-16                 | NULL                      |
| s                    | 2020-01-14             | 2020-01-16                 | NULL                      |
| t                    | 2020-01-15             | 2020-01-15                 | NULL                      |
| u                    | 2020-01-15             | 2020-01-16                 | NULL                      |
| v                    | 2020-01-15             | 2020-01-16                 | NULL                      |
+----------------------+------------------------+----------------------------+---------------------------+

尝试解决方案二 修改hdfs文件对于的用户 和 权限 修改后未解决

  • hdfs dfs -chown root /user/hive/warehouse/project1.db/demo_ads_apl_nrt
  • hdfs dfs -ch’mo’d 777 /uschmoder/hive/warehouse/project1.db/demo_ads_apl_nrt

尝试解决方案三 配置hdfs-site.xml 文件权限 配置后未解决问题

尝试解决方案四 使用 # hive 客户端运行正常

尝试解决方案五 终极大招 重剑无锋 看似最简单的招式就是最牛逼的招式 重新启动hiveServer2服务 后 运行正常

总结 是 hiveServer2服务的某个进程挂了造成的问题

No rows selected (0.184 seconds)
0: jdbc:hive2://localhost:10000> INSERT INTO TABLE ADS_APL_NRT_DEMO
. . . . . . . . . . . . . . . .> SELECT 
. . . . . . . . . . . . . . . .> first_dt    as    dt,
. . . . . . . . . . . . . . . .> count(1)    as    dnu_cnts,
. . . . . . . . . . . . . . . .> datediff('2020-01-16',first_dt) as nrt_days,
. . . . . . . . . . . . . . . .> count(if(last_dt='2020-01-16',1,null)) as nrt_users
. . . . . . . . . . . . . . . .> FROM DEMO_DWS_APL_HSU_REC
. . . . . . . . . . . . . . . .> GROUP BY first_dt
. . . . . . . . . . . . . . . .> ;
WARNING: Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
No rows affected (2.761 seconds)
0: jdbc:hive2://localhost:10000> 
发布了33 篇原创文章 · 获赞 12 · 访问量 3326

猜你喜欢

转载自blog.csdn.net/IT_BULL/article/details/104021624