关于return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask 错误

1.解决return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask 错误

在启动hive后,使用select查询语句进行查询时,爆出如下错误:

INFO  : Number of reduce tasks determined at compile time: 1

INFO  : In order to change the average load for a reducer (in bytes):
INFO  :   set hive.exec.reducers.bytes.per.reducer=<number>
INFO  : In order to limit the maximum number of reducers:
INFO  :   set hive.exec.reducers.max=<number>
INFO  : In order to set a constant number of reducers:
INFO  :   set mapreduce.job.reduces=<number>
INFO  : number of splits:1
INFO  : Submitting tokens for job: job_1500138723273_0001
INFO  : The url to track the job: http://hadoop01:8088/proxy/application_1500138723273_0001/
INFO  : Starting Job = job_1500138723273_0001, Tracking URL = http://hadoop01:8088/proxy/application_1500138723273_0001/
INFO  : Kill Command = /home/hadoop/soft/hadoop-2.6.4/bin/hadoop job  -kill job_1500138723273_0001
INFO  : Hadoop job information for Stage-1: number of mappers: 0; number of reducers: 0
INFO  : 2017-07-19 22:57:22,349 Stage-1 map = 0%,  reduce = 0%
ERROR : Ended Job = job_1500138723273_0001 with errors
Error: Error while processing statement: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask (state=08S01,code=2)

在查看日志信息以后,发现错误的原因在于namenode处于safemode状态,然后进入namenode所在节点通过使用hdfs dfsadmin -safemode leave命令退出安全模式,就可以解决问题。

2.解决return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapredLocalTask错误

通过查看日志可以看出报错的类MapredLocalTask可以看出跟本地任务有关,所以我们可以通过以下几个参数对相关行为进行设置

  hive.exec.mode.local.auto=false
hive.exec.mode.local.auto.input.files.max=4
其中第一个为不启用本地模式,第二个参数表示文件数小于4时使用本地模式,第三个参数表示文件大小小于128m时采用本地模式
默认为不启用本地模式;在启用的情况下,满足第二、三个条件中的任意一个都会使用本地模式。hive.exec.mode.local.auto.inputbytes.max=134217728

任务是在root用户下通过crontab调用的,进入shell后先启动hiveserver,所以默认工作目录其实是/root;为了能正常读写hdfs上的文件,hiveserver在启动时切换到了hdfs用户,一旦遇到上述两种满足启用本地模式的情况,hdfs用户试图向当前工作目录/root拉取数据,必然没有权限从而导致以上错误。

        理清问题所在就好办了,我们可以先创建一个目录,把用户、用户组授权给hdfs,进入shell后,先切换工作目录,然后再启动hiveserver即可。如hdfs的home目录/home/hdfs
然后在任务shell的公共配置文件conf/kettle.conf中增加一行切换目录脚本即可解决以上问题
cd /home/hdfs



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值