hbase整合hive

将对 hbase-0.90.6 hive-0.8.1 进行集成,使用的 hadoop-0.20.2

1. 首先将 hbase-0.90.6.jar zookeeper-3.3.2.jar 复制到 hive/lib 目录下

注意:如果 hive/lib 下已经存在这两个文件的其他版本(例如 zookeeper-3.3.1.jar ),建议删除后使用 hbase 下的相关版本

 

2. hive/conf hive-site.xml 文件中添加如下的内容:

<property>

<name>hive.aux.jars.path</name>

<value>file:///home/hadoop/hadoop/hive-0.8.1/lib/hive-hbase-handler-0.8.1.jar,file:///home/hadoop/hadoop/hive-0.8.1/lib/hbase-0.90.6.jar,file:///home/hadoop/hadoop/hive-0.8.1/lib/zookeeper-3.3.2.jar</value>

</property>

这个需要根据自己的具体文件路径指定

 

3. 拷贝 hbase-0.90.6.jar 到所有 hadoop 节点 ( 包括 master) hadoop/lib

 

4. 拷贝 hbase/conf 下的 hbase-site.xml 文件到所有 hadoop 节点 ( 包括 master) hadoop/conf

 

5. 单结点启动 hive ,伪分布式属于单结点:

bin/hive -hiveconf hbase.master=localhost:60000

 

集群启动:

bin/hive -hiveconf hbase.zookeeper.quorum=slave

如何 hive-site.xml 文件中没有配置 hive.aux.jars.path ,则可以按照如下方式启动。

bin/hive --auxpath /usr/local/hive/lib/hive-hbase-handler-0.8.0.jar, /usr/local/hive/lib/hbase-0.90.5.jar, /usr/local/hive/lib/zookeeper-3.3.2.jar

-hiveconf hbase.zookeeper.quorum=slave

 

6. 创建 hbase 识别的数据,这个操作在 hive 下进行:

create table hive_hbase(key string,age int,sex int) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' with SERDEPROPERTIES("hbase.columns.mapping" = ":key,cf1:age,cf1:sex")tblproperties("hbase.table.name" = "hbase_hive");

 

7. hbase 下面查看数据:

list

 

8. 创建临时表 person

create table person(name string, age int, sex int) row format delimited fields terminated by '\t' stored as textfile;

 

9. 往临时表中添加数据:

load data local inpath '/home/hadoop/Desktop/data.txt' overwrite into table person;

 

 

10. hive_hbase 表中添加数据:

insert overwrite table hive_hbase select * from person;

 

11. 查看表中数据:

select * from person limit 5;

 

12.hbase 中查看数据:

scan 'hbase_hive'

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值