TECH SOLUTIONS

Click here to edit subtitle

Forums

Post Reply
Forum Home > Bigdata Learnings( Hadoop, HBase,Hive and other bigdata technologies) > Hive/HBase Integration ( Enter data in hbase table using hive)

Sourav Gulati
Site Owner
Posts: 83

For hive 0.6 or lesser,  use hbase-0.26.  If we want to use hbase-xxx xxx>0.26, use hive-0.7 or greater.

1)    Software requisite ( Flowing are the software stack I used )

      . hadoop

      . hbase

      . hive


2)   Assuming we have Hadoop , Hbase & Hive installed & hadoop and Hbase are up and running.


3)   Go tolib folder in hive instillation and look for hbase-xx version.  This should match the  hbase master that we have started. If not we can  replace the correct version of jars. Make sure the delete or rename the previous HBase jar after copying correct version of jars.

     Perform the same operation for zookeeper


4) Run following command from HiVE_HOME to start HIVE CLI


   bin/hive --auxpath $HIVE_HOME/lib/hive-hbase-handler-0.8.1.jar,$HIVE_HOME/lib/hbase-0.92.1.jar,$HIVE_HOME/lib/zookeeper-3.4.3.jar,$HIVE_HOME/lib/guava-r06.jar -hiveconf hbase.zookeeper.quorum=zk(addreess of zookeeper system)


    If there are multiple zookeepers then run it as follows:  


    bin/hive --auxpath $HIVE_HOME/lib/hive-hbase-handler-0.8.1.jar,$HIVE_HOME/lib/hbase-0.92.1.jar,$HIVE_HOME/lib/zookeeper-3.4.3.jar,$HIVE_HOME/lib/guava-r06.jar -hiveconf hbase.zookeeper.quorum=zk1,zk2,zk3


  Make sure you correct the version of jar as per your setup

    Also , you can set "HIVE_AUX_JARS_PATH" variable in hive-env.sh and add these jars there

     Note:$HADOOP_HOME must be set or hadoop must be in the path


5)In order to create a new HBase table which is to be managed by Hive, run below command from Hive.             


  CREATE TABLE hbase_table(key int, value string)               

STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'              

WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:val")               T

TBLPROPERTIES ("hbase.table.name" = "xyz");


  The table is known as hbase_table within Hive, and as xyz within Hbase.

  Here we created physical table. IF table already exists in HBase, you can create External Table in Hive.     


6) We can cross check in Hbase shell givinglist command. It will list down the table “XYZ”.


7)    Try inserting records from Hive to Hbase by giving command.


     INSERT INTO TABLE hbase_table SELECT 1,'test' from dummy limit 1;


8 )   Use HBase shell to verify that the data actually got loaded through command scan "xyz"


Click here for Other topics of BigData Technologies

 

February 6, 2013 at 6:25 AM Flag Quote & Reply

You must login to post.