官方文档:https://cwiki.apache.org/confluence/display/Hive/HBaseIntegration

1、把hive/lib下的hive-hbase-handler-1.2.1.jar  cp到hbase/lib 下

2、同时把hbase中的所有的jar,cp到hive/lib

3、在hive的配置文件增加属性:指定hbase地址

  <property>
    <name>hbase.zookeeper.quorum</name>
    <value>node01</value>
  </property>

4、创建hive表 管理 hbase表,数据存储在hbase中

-- 创建hive表 管理 hbase表
create external table event_logs(
key string, pl string, en string, s_time bigint, p_url string, u_ud string, u_sd string
)
row format
serde 'org.apache.hadoop.hive.hbase.HBaseSerDe' -- 指定格式化类
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' -- 指定存储类
-- 指定序列化参数,按顺序指定列对应的hbase表列
-- :key rowkey
-- log:p1  列族:列名
with serdeproperties('hbase.columns.mapping' = ':key,log:pl,log:en,log:s_time,log:p_url,log:u_ud,log:u_sd')
-- 表名
tblproperties('hbase.table.name'='eventlog');

如果是创建内部表则需要提前在hbase中创建该表

如果是外部表则不需要,一般创建外部表,hive只做为管理

添加新评论