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");
![](https://images2017.cnblogs.com/blog/1250469/201801/1250469-20180122181920584-264020352.png)
![](https://images2017.cnblogs.com/blog/1250469/201801/1250469-20180122182041069-1705388427.png)