繼上篇博客,hive鏈接hbase外部表成功後,能夠正常的查詢hbase的數據了。可是向hbase插入數據卻報錯了。
java
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 mysql
的Hive 1.2.1-1601 Release Notes的說明,fe18d11的commit的說明中和我當前錯誤一致的。可是這個MapR公司對hive版本的一個patch,我用的是apache的版本,改到MapR的hive版本不現實啊,嘗試按照他補丁包中的updated,進行更新我本身的hive的jar包和配置,發現又引出新的問題。這種方式不行啊,得換條路了。sql
查看hive官方的發佈版本,當前有兩個版本apache-hive-1.2.1-bin.tar.gz和apache-hive-2.0.0-bin.tar.gz 。我當前是1.2.1的,我能夠升級到2.0.0試一下。shell
下載2.0.0版本並安裝,主要是修改了hive-site.xml文件(執行cp hive-default.xml.template hive-site.xml)。同時在hive/lib目錄下引入hbase的jar包:apache
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
session
<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>
老外真能寫,一個配置文件快5000行了,都改蒙圈了。app
修改配置文件後,啓動metaStore的後臺進程,執行hive就可進入hive的命令行了,執行insert into table hbase的表,執行成功。歐耶!oop