1

我有一个 hive+hbase 集成集群。

当我尝试通过 hive 的 java 客户端执行查询时,有时ClassNotFoundException发生。

我的Java代码:

final Connection conn = DriverManager.getConnection(URL);
final ResultSet rs = conn.executeQuery("SELECT count(*) FROM test_table WHERE (source = '0' AND ur_createtime BETWEEN '20121031000000' AND '20121031235959')");

我可以在 hive cli mod 中执行 sql:SELECT count(*) FROM test_table WHERE (source = '0' AND ur_createtime BETWEEN '20121031000000' AND '20121031235959')并获取查询结果,所以我的 sql 中没有错误。

客户端异常:

Caused by: java.sql.SQLException: Query returned non-zero code: 9, cause: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.MapRedTask
    at org.apache.hadoop.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:189)
... 23 more

服务器端异常(hadoop-jobtracker):

2012-11-05 18:55:39,443 INFO org.apache.hadoop.mapred.TaskInProgress: Error from attempt_201210301133_0112_m_000000_3: java.io.IOException: Cannot create an instance of InputSplit class = org.apache.hadoop.hive.hbase.HBaseSplit:org.apache.hadoop.hive.hbase.HBaseSplit
    at org.apache.hadoop.hive.ql.io.HiveInputFormat$HiveInputSplit.readFields(HiveInputFormat.java:146)
    at org.apache.hadoop.io.serializer.WritableSerialization$WritableDeserializer.deserialize(WritableSerialization.java:67)
    at org.apache.hadoop.io.serializer.WritableSerialization$WritableDeserializer.deserialize(WritableSerialization.java:40)
    at org.apache.hadoop.mapred.MapTask.getSplitDetails(MapTask.java:396)
    at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:412)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:372)
    at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Unknown Source)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1059)
    at org.apache.hadoop.mapred.Child.main(Child.java:249)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.hive.hbase.HBaseSplit
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:819)
    at org.apache.hadoop.hive.ql.io.HiveInputFormat$HiveInputSplit.readFields(HiveInputFormat.java:143)
    ... 10 more

我的 hive-env.sh

export HIVE_AUX_JARS_PATH=/data/install/hive-0.9.0/lib/hive-hbase-handler-0.9.0.jar,/data/install/hive-0.9.0/lib/hbase-0.92.0.jar,/data/install/hive-0.9.0/lib/zookeeper-3.4.2.jar

我的 hive-site.xml

<property>
    <name>hive.zookeeper.quorum</name>
    <value>hadoop01,hadoop02,hadoop03</value>
    <description>The list of zookeeper servers to talk to. This is only needed for read/write locks.</description>
</property>

我开始节俭服务如下:

hive --service hiveserver -p 10000 &

服务器端错误日志显示HBaseSplit未找到。但为什么?我怎样才能解决这个问题?

4

3 回答 3

2

如果您无权访问配置文件,您可以使用 --auxpath 开关将 jars 添加到 hive cli 类路径:

hive --auxpath /path/to/hive-hbase-handler-0.10.0-cdh4.2.0.jar,/path/to/hbase.jar 
于 2013-10-09T14:56:39.803 回答
1
  1. 在 $HIVE_HOME 中创建一个文件夹 auxlib 并将所有 hive-hbase-handler、hbase jar 放入该文件夹

  2. 将以下行添加到 $HIVE_HOME/conf/hive-site.xml

    <property>
     <name>hive.aux.jars.path</name>
     <value>file:///<absolute-path-of-all-auxlib-jars></value>
    </property>
    

    重新启动配置单元服务器

于 2013-03-17T20:31:28.757 回答
0

此问题的解决方法是您可以将 jar 文件 hive-hbase-handler-0.9.0-cdh4.1.2、hbase-0.92.1-cdh4.1.2-security 等复制到 HADOOP lib 文件夹或添加这些 jar 的路径在 HADOOP_CLASSPATH 环境变量中。

于 2013-01-23T13:14:18.147 回答