本篇内容主要讲解“hive连接hbase外部表时insert数据报错怎么办”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“hive连接hbase外部表时insert数据报错怎么办”吧!
hive连接hbase外部表成功后,可以正常的查询hbase的数据了。但是向hbase插入数据却报错了。
Error: java.lang.RuntimeException: java.lang.NoSuchMethodError: org.apache.hadoop.hbase.client.Put.setDurability(Lorg/apache/hadoop/hbase/client/Durability;)V at org.apache.hadoop.hive.ql.exec.mr.ExecMapper.map(ExecMapper.java:168) at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:54) at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:453) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343) at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164) 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:1657) at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158) Caused by: java.lang.NoSuchMethodError: org.apache.hadoop.hbase.client.Put.setDurability(Lorg/apache/hadoop/hbase/client/Durability;)V at org.apache.hadoop.hive.hbase.HiveHBaseTableOutputFormat$MyRecordWriter.write(HiveHBaseTableOutputFormat.java:142) at org.apache.hadoop.hive.hbase.HiveHBaseTableOutputFormat$MyRecordWriter.write(HiveHBaseTableOutputFormat.java:117) at org.apache.hadoop.hive.ql.io.HivePassthroughRecordWriter.write(HivePassthroughRecordWriter.java:40) at org.apache.hadoop.hive.ql.exec.FileSinkOperator.process(FileSinkOperator.java:743) at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:837) at org.apache.hadoop.hive.ql.exec.SelectOperator.process(SelectOperator.java:97) at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:837) at org.apache.hadoop.hive.ql.exec.TableScanoperator.process(TableScanoperator.java:115) at org.apache.hadoop.hive.ql.exec.MapOperator$MapOpCtx.forward(MapOperator.java:169) at org.apache.hadoop.hive.ql.exec.MapOperator.process(MapOperator.java:561) at org.apache.hadoop.hive.ql.exec.mr.ExecMapper.map(ExecMapper.java:159) ... 8 more
在网上查找问题,发现MapR解决过这个问题,参考页面http://doc.mapr.com/display/components/Hive+Release+Notes;jsessionid=73C03B3BB0D8547A19E6CCEF80010D30#HiveReleaseNotes-Hive1.2.1-1601ReleaseNotes
的Hive 1.2.1-1601 Release Notes的说明,fe18d11的commit的说明中和我当前错误一致的。但是这个MapR公司对hive版本的一个patch,我用的是apache的版本,改到MapR的hive版本不现实啊,尝试按照他补丁包中的updated,进行更新我自己的hive的jar包和配置,发现又引出新的问题。这种方式不行啊,得换条路了。
查看hive官方的发布版本,当前有两个版本apache-hive-1.2.1-bin.tar.gz和apache-hive-2.0.0-bin.tar.gz 。我当前是1.2.1的,我可以升级到2.0.0试一下。
下载2.0.0版本并安装,主要是修改了hive-site.xml文件(执行cp hive-default.xml.template hive-site.xml)。同时在hive/lib目录下引入hbase的jar包:
guava-14.0.1.jar protobuf-java-2.5.0.jar hbase-client-1.1.1.jar hbase-common-1.1.1.jar zookeeper-3.4.6.jar hbase-server-1.1.1.jar
hive-site.xml
<property> <name>hive.exec.scratchdir</name> <value>/tmp/hive</value> <description>HDFS root scratch dir for Hive jobs which gets created with write all (733) permission. For each connecting user, an HDFS scratch dir: ${hive.exec.scratchdir}/<username> is created, with ${hive.scratch.dir.permission}.</description> </property> <property> <name>hive.exec.local.scratchdir</name> <value>/data/hive/logs</value> <description>Local scratch space for Hive jobs</description> </property> <property> <name>hive.downloaded.resources.dir</name> <value>/tmp/hive/temp0_resources</value> <description>Temporary local directory for added resources in the remote file system.</description> </property> ... <property> <name>javax.jdo.option.ConnectionPassword</name> <value>password</value> <description>password to use against metastore database</description> </property> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/hive_db?createDatabaseIfNotExist=true</value> <description>JDBC connect string for a JDBC metastore</description> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.MysqL.jdbc.Driver</value> <description>Driver class name for a JDBC metastore</description> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>username</value> <description>Username to use against metastore database</description> </property> <property> <name>hive.session.id</name> <value>temp0</value> <description/> </property> <property> <name>hive.aux.jars.path</name> <value>file:///data/hive/lib/guava-14.0.1.jar,file:///data/hive/lib/protobuf-java-2.5.0.jar,file:///data/hive/lib/hbase-client-1.1.1.jar,file:///data/hive/lib/hbase-common-1.1.1.jar,file:///data/hive/lib/zookeeper-3.4.6.jar,file:///data/hive/lib/hbase-server-1.1.1.jar</value> <description>The location of the plugin jars that contain implementations of user defined functions and serdes.</description> </property> <property> <name>hive.querylog.location</name> <value>/data/hive/logs</value> <description>Location of Hive run time structured log file</description> </property> <property> <name>hive.zookeeper.quorum</name> <value>slave1,slave2,master,slave4,slave5,slave6,slave7</value> <description> List of ZooKeeper servers to talk to. This is needed for: 1. Read/write locks - when hive.lock.manager is set to org.apache.hadoop.hive.ql.lockmgr.zookeeper.ZooKeeperHiveLockManager, 2. When HiveServer2 supports service discovery via Zookeeper. 3. For delegation token storage if zookeeper store is used, if hive.cluster.delegation.token.store.zookeeper.connectString is not set </description> </property> <property> <name>hbase.zookeeper.quorum</name> <value>slave1,slave2,master,slave4,slave5,slave6,slave7</value> </property> <property> <name>hive.server2.logging.operation.log.location</name> <value>/data/hive/logs/operation_logs</value> <description>Top level directory where operation logs are stored if logging functionality is enabled</description> </property>
修改配置文件后,启动metastore的后台进程,执行hive就可进入hive的命令行了,执行insert into table hbase的表,执行成功。
到此,相信大家对“hive连接hbase外部表时insert数据报错怎么办”有了更深的了解,不妨来实际操作一番吧!这里是编程之家网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!