转个解决 MapredLocalTask的帖子
我的问题是目录没有其他用户读权限,所以报错
http://vase.iteye.com/blog/2090320
不知道是不是hive-0.12版增强了local mode的原因,在之前版本运行好好的Hive-QL在这个版本上错误频频,折磨一天多以后终于定位到原因,把在内部的总结在这再记录下,希望对遇到同样问题的筒子们有所帮助。
部分一 关于return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapredLocalTask
Hive升级到0.12版之后,若干原来在0.10上执行正常的SQL会在新版上报错误 “return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapredLocalTask”,查看hive执行日志,从中找到如下错误
- Total MapReduce jobs = 1
- java.io.IOException: Cannot run program "/data/opt/hadoop_cdh5/bin/hadoop" (in directory "/root"): error=13, 权限不够
- at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
- at java.lang.Runtime.exec(Runtime.java:617)
- at java.lang.Runtime.exec(Runtime.java:450)
- at org.apache.hadoop.hive.ql.exec.mr.MapredLocalTask.execute(MapredLocalTask.java:253)
- at org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:151)
- at org.apache.hadoop.hive.ql.exec.TaskRunner.runSequential(TaskRunner.java:65)
- at org.apache.hadoop.hive.ql.Driver.launchTask(Driver.java:1485)
- at org.apache.hadoop.hive.ql.Driver.execute(Driver.java:1263)
- at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1091)
- at org.apache.hadoop.hive.ql.Driver.run(Driver.java:931)
- at org.apache.hadoop.hive.ql.Driver.run(Driver.java:921)
- at org.apache.hadoop.hive.service.HiveServer$HiveServerHandler.execute(HiveServer.java:198)
- at org.apache.hadoop.hive.service.ThriftHive$Processor$execute.getResult(ThriftHive.java:644)
- at org.apache.hadoop.hive.service.ThriftHive$Processor$execute.getResult(ThriftHive.java:628)
- at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39)
- at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)
- at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:244)
- at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
- at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
- at java.lang.Thread.run(Thread.java:744)
- Caused by: java.io.IOException: error=13, 权限不够
- at java.lang.UNIXProcess.forkAndExec(Native Method)
- at java.lang.UNIXProcess.<init>(UNIXProcess.java:135)
- at java.lang.ProcessImpl.start(ProcessImpl.java:130)
- at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
- ... 19 more
- FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapredLocalTask
从上边错误及下边报错的类MapredLocalTask可以看出跟本地任务有关
hive从0.7版以后,为了提高小数据的计算速度,增加了本地模式,即将hdfs上的数据拉到hiveserver本地进行计算,可以通过以下几个参数对相关行为进行设置
hive.exec.mode.local.auto.input.files.max=4
hive.exec.mode.local.auto.inputbytes.max=134217728
类似上一篇中return code 1的问题,这个也是跟hive本地任务有关系。
从hive的日志中可以找到出错时本地日志文件,如下:
查看日志文件内容
- 2014-07-10 11:50:37,606 INFO mr.ExecDriver (SessionState.java:printInfo(417)) - Execution log at: /tmp/hdfs/hdfs_20140710114949_ab4d1d02-0637-4abd-9e45-2a27c5d740d9.log
- 2014-07-10 11:50:37,711 WARN conf.Configuration (Configuration.java:loadProperty(2358)) - file:/tmp/hdfs/hive_2014-07-10_11-49-37_877_2428431256361163465-1/-local-10009/jobconf
- 2014-07-10 11:50:37,720 WARN conf.Configuration (Configuration.java:loadProperty(2358)) - file:/tmp/hdfs/hive_2014-07-10_11-49-37_877_2428431256361163465-1/-local-10009/jobconf
- 2014-07-10 11:50:37,798 INFO log.PerfLogger (PerfLogger.java:PerfLogBegin(97)) - <PERFLOG method=deserializePlan from=org.apache.hadoop.hive.ql.exec.Utilities>
- 2014-07-10 11:50:37,798 INFO exec.Utilities (Utilities.java:deserializePlan(732)) - Deserializing MapredLocalWork via kryo
- 2014-07-10 11:50:38,043 INFO log.PerfLogger (PerfLogger.java:PerfLogEnd(124)) - </PERFLOG method=deserializePlan start=1404964237798 end=1404964238043 duration=245 from=org.apa
- 2014-07-10 11:50:38,050 INFO mr.MapredLocalTask (SessionState.java:printInfo(417)) - 2014-07-10 11:50:38 Starting to launch local task to process map join; maximum memory =
- 2014-07-10 11:50:38,059 INFO mr.MapredLocalTask (MapredLocalTask.java:initializeOperators(389)) - fetchoperator for t2:t_tmp_user_first_login created
- 2014-07-10 11:50:38,198 INFO exec.TableScanOperator (Operator.java:initialize(338)) - Initializing Self 0 TS
- 2014-07-10 11:50:38,198 INFO exec.TableScanOperator (Operator.java:initializeChildren(403)) - Operator 0 TS initialized
- 2014-07-10 11:50:38,199 INFO exec.TableScanOperator (Operator.java:initializeChildren(407)) - Initializing children of 0 TS
- 2014-07-10 11:50:38,199 INFO exec.SelectOperator (Operator.java:initialize(442)) - Initializing child 1 SEL
- 2014-07-10 11:50:38,199 INFO exec.SelectOperator (Operator.java:initialize(338)) - Initializing Self 1 SEL
- 2014-07-10 11:50:38,605 ERROR mr.MapredLocalTask (MapredLocalTask.java:executeFromChildJVM(324)) - Hive Runtime Error: Map local work failed
- java.lang.RuntimeException: java.lang.ClassNotFoundException: com.renren.hive.date.GetWeekISO
- at org.apache.hadoop.hive.ql.udf.generic.GenericUDFBridge.getUdfClass(GenericUDFBridge.java:132)
- at org.apache.hadoop.hive.ql.exec.FunctionRegistry.isStateful(FunctionRegistry.java:1474)
- at org.apache.hadoop.hive.ql.exec.FunctionRegistry.isDeterministic(FunctionRegistry.java:1437)
- at org.apache.hadoop.hive.ql.exec.ExprNodeGenericFuncEvaluator.isDeterministic(ExprNodeGenericFuncEvaluator.java:132)
- at org.apache.hadoop.hive.ql.exec.ExprNodeEvaluatorFactory.iterate(ExprNodeEvaluatorFactory.java:83)
- at org.apache.hadoop.hive.ql.exec.ExprNodeEvaluatorFactory.toCachedEval(ExprNodeEvaluatorFactory.java:73)
- at org.apache.hadoop.hive.ql.exec.SelectOperator.initializeOp(SelectOperator.java:59)
- at org.apache.hadoop.hive.ql.exec.Operator.initialize(Operator.java:377)
- at org.apache.hadoop.hive.ql.exec.Operator.initialize(Operator.java:453)
- at org.apache.hadoop.hive.ql.exec.Operator.initializeChildren(Operator.java:409)
- at org.apache.hadoop.hive.ql.exec.TableScanOperator.initializeOp(TableScanOperator.java:188)
- at org.apache.hadoop.hive.ql.exec.Operator.initialize(Operator.java:377)
- at org.apache.hadoop.hive.ql.exec.mr.MapredLocalTask.initializeOperators(MapredLocalTask.java:408)
- at org.apache.hadoop.hive.ql.exec.mr.MapredLocalTask.executeFromChildJVM(MapredLocalTask.java:302)
- at org.apache.hadoop.hive.ql.exec.mr.ExecDriver.main(ExecDriver.java:728)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
- at java.lang.reflect.Method.invoke(Method.java:606)
- at org.apache.hadoop.util.RunJar.main(RunJar.java:212)
- Caused by: java.lang.ClassNotFoundException: com.renren.hive.date.GetWeekISO
- at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
- at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
- at java.security.AccessController.doPrivileged(Native Method)
- at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
- at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
- at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
- at java.lang.Class.forName0(Native Method)
- at java.lang.Class.forName(Class.java:270)
- at org.apache.hadoop.hive.ql.udf.generic.GenericUDFBridge.getUdfClass(GenericUDFBridge.java:130)
由上可知,这次是找不到UDF的类(如遇到其他情况,需要具体问题具体分析),虽然在进入hive的时候通过add jar语句将自定义函数的jar包添加到hadoop集群,但在本地模式时确找不到了。定位到问题就好解决了:既然是local模式找不到udf jar包,说明在add jar步骤只是向当前job在hdfs上的工作目录下添加了,无视本地工作目录;那么我们就直接把udf的jar包copy到hive的lib目录下,测 试正常。
该问题在之前用过的hive 0.10、0.8.1中都未遇到过,初步猜测跟0.12版的bug有关,具体原因就需要花时间翻代码对照前后版本的变动了
从org.apache.hadoop.hive.ql.exec.mr.MapredLocalTask代码中看,还有return code 3的情况,现在幸运的尚未遇到,遇到后再补记录