hive整合Hbase

实验步骤:

1.修改配置文件

到/opt/software/hive-2.3.3/conf目录下修改hive-site.xml文件以及hive-env.sh文件配置

hive-site.xml:

<property>

    <name>hive.zookeeper.quorum</name>

    <value>node01,node02,node03</value>

</property>

<property>

    <name>hbase.zookeeper.quorum</name>

    <value>node01,node02,node03</value>

</property>

<property>

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

    <value>file:///opt/software/hive/lib/hive-hbase-handler-2.3.3.jar,file:///opt/software/hive/lib/zoo

keeper-3.4.10.jar,file:///opt/software/hive/lib/hbase-client-1.3.1.jar,file:///opt/software/hive/lib/hbase-common-1.3.1-tests.jar,file:///opt/software/hive/lib/hbase-server-1.3.1.jar,file:///opt/software/hive/lib/hbase-common-1.3.1.jar,file:///opt/software/hive/lib/hbase-protocol-1.3.1.jar,file:///opt/software/hive/lib/htrace-core-3.1.0-incubating.jar

    </value>

</property>

hive-env.sh: 

 

2.将hbase lib目录下的所有文件复制到hive lib目录中

注意:先删除hive/lib目录下hbase开头的jar包

/opt/software/hive/lib目录下:

rm -rf hbase-*

/opt/software/hbase/lib目录下:

cp * /opt/software/hive/lib/

3. 在hive中创建映射表,创建完成后在hbase中查看是否同时在hbase中也创建成功(创建之前要先启动hbase

start-hbase.sh

 

 

 

进入到hive

创建表

create table hbase_score(id int,name string,score int) stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' with serdeproperties("hbase.columns.mapping" = "cf:name,cf:score") tblproperties("hbase.table.name" = "hbase_score");

create table hive_hbase_test(id int,name string) stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' with serdeproperties("hbase.columns.mapping"=":key,cf1:name") tblproperties("hbase.table.name"="hive_hbase_test");

 

 

hbae shell

list

 

4. 导入数据测试:

Hive 导入数据,Hbase查看数据:

1vi hive_hbase.txt

2)在hive中创表,导入数据:

create table test(id int,name string) row format delimited fields terminated by ',';

load data local inpath "/opt/testData/hive/hive_hbase.txt" into table test;

select * from test;

 

 

3)将hive的test表中的数据加载到hive_hbase_test表

insert overwrite table hive_hbase_test select * from test;

 

通过Hbase put添加数据,Hive查看添加数据

1)在hbase shell中对表hive_hbase_test添加数据

put 'hive_hbase_test','4','cf1:name','mipeng'

 

2)在hive中查看数据是否添加进来:

select * from hive_hbase_test;

 

注意事项:

整合完成之后,如果在hive当中创建的为内部表,那么在hive中删除该表时,hbase上对应的表也会删除;如果在hive当中创建的为外部表,那么在hive中删除该表时,不会影响hbase。

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值