java—如何为从HiveJDBC查询启动的mr作业指定其他JAR?

bnl4lu3b  于 2021-06-04  发布在  Hadoop
关注(0)|答案(2)|浏览(589)

我试图通过使用avro存储格式的jdbc查询一个配置单元表,但是在查询产生的mr作业中发现了一个class not found错误。奇怪的是,我可以在没有异常发生的情况下从hiveshell运行查询。
我可以运行不生成map reduce作业的查询( select * from table limit 10 )而且效果很好。

2014-03-12 10:23:34,040 WARN [main] org.apache.hadoop.mapred.YarnChild: Exception running child : java.io.IOException: java.lang.reflect.InvocationTargetException
    at org.apache.hadoop.hive.io.HiveIOExceptionHandlerChain.handleRecordReaderCreationException(HiveIOExceptionHandlerChain.java:97)
    at org.apache.hadoop.hive.io.HiveIOExceptionHandlerUtil.handleRecordReaderCreationException(HiveIOExceptionHandlerUtil.java:57)
    at org.apache.hadoop.hive.shims.HadoopShimsSecure$CombineFileRecordReader.initNextRecordReader(HadoopShimsSecure.java:344)
    at org.apache.hadoop.hive.shims.HadoopShimsSecure$CombineFileRecordReader.<init>(HadoopShimsSecure.java:291)
    at org.apache.hadoop.hive.shims.HadoopShimsSecure$CombineFileInputFormatShim.getRecordReader(HadoopShimsSecure.java:405)
    at org.apache.hadoop.hive.ql.io.CombineHiveInputFormat.getRecordReader(CombineHiveInputFormat.java:560)
    at org.apache.hadoop.mapred.MapTask$TrackedRecordReader.<init>(MapTask.java:168)
    at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:409)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:342)
    at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:165)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:415)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1548)
    at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:160)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.apache.hadoop.hive.shims.HadoopShimsSecure$CombineFileRecordReader.initNextRecordReader(HadoopShimsSecure.java:330)
    ... 11 more
Caused by: java.lang.NoClassDefFoundError: org/apache/avro/mapred/FsInput
    at org.apache.hadoop.hive.ql.io.avro.AvroGenericRecordReader.<init>(AvroGenericRecordReader.java:82)
    at org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat.getRecordReader(AvroContainerInputFormat.java:51)
    at org.apache.hadoop.hive.ql.io.CombineHiveRecordReader.<init>(CombineHiveRecordReader.java:65)
    ... 16 more
Caused by: java.lang.ClassNotFoundException: org.apache.avro.mapred.FsInput
    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:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 19 more
nkoocmlb

nkoocmlb1#

解决方案是为创建的每个新连接执行以下sql stmt。

add jar /hive-ext/avro-mapred-1.7.5-cdh5.0.0-beta-2-hadoop2.jar ;

这条路 /hive-ext 在运行配置单元服务器的同一台计算机上的配置单元服务器ie上是本地的
一定要改变你的陈述,以符合你的名字 avro-mapred jar文件

hl0ma9xz

hl0ma9xz2#

可能 hive.aux.jars.path :包含用户定义函数和serde实现的插件jar的位置。cli可以从jdbc hiverserver/hiverservre2获取另一个配置值。试着跑步 set hive.aux.jars.path; 并在两种环境下对结果进行比较。在这里,denny将所有avro jar添加到hive-site.xml中的hive.aux.jars.path。

相关问题