Hive篇---Hive与Hbase整合

 一、前述

Hive会经常和Hbase结合使用,把Hbase作为Hive的存储路径,所以Hive整合Hbase尤其重要。

二、具体步骤

hive和hbase同步
https://cwiki.apache.org/confluence/display/Hive/HBaseIntegration

1、把hive-hbase-handler-1.2.1.jar  cp到hbase/lib 下
    同时把hbase中的所有的jar,cp到hive/lib

2、在hive的配置文件增加属性:
  <property>
    <name>hbase.zookeeper.quorum</name>
    <value>node5,node6,node7</value>
  </property>

3、在hive中创建临时表

CREATE EXTERNAL TABLE tmp_order
(key string, id string, user_id string)  
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'  
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,order:order_id,order:user_id")  
TBLPROPERTIES ("hbase.table.name" = "t_order");

CREATE TABLE hbasetbl(key int, value string)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:val")
TBLPROPERTIES ("hbase.table.name" = "xyz", "hbase.mapred.output.outputtable" = "xyz");

注意:
1. hive  是hbase的客户端
数据在Hbase中存储。
需要知道hbase的zookeeper集群。。
 
2. 映射关系:
 
 
 
3. 外部表不可以,因为hive不管理数据,所以不会帮hbase创建表,得在hbase中先创建表。所以最好创建外部表!!!
 
4.版本依赖需要注意!!!
 
原文地址:https://www.cnblogs.com/LHWorldBlog/p/8330485.html