Hive和Hbase整合

  • 整合hbase和hive:

              1. 在hive-site.xml里面添加:

           <property>

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

                   <value>file:///usr/lib/hive/lib/hive-hbase-handler-0.9.0-cdh4.1.0.jar,file:///usr/lib/hbase/hbase-0.94.2-cdh4.2.0-security.jar,file:///usr/lib/zookeeper/zookeeper.jar</value>

           </property>

           <property>

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

                    <value>SVR2368HP360,SVR2369HP360,SVR2370HP360</value>

           </property>

2. 创建hive里面对应hbase的表(相当于hive对hbase的视图):

             CREATE EXTERNAL TABLE test_sqoop(

                 a string,

                 b string,

                 c string,

                 x string,

                 y string

             )       

             STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 

             WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf:b,cf:c,cf:x,cf:y") 

             TBLPROPERTIES("hbase.table.name" = "test_sqoop");

 

  • 导hive数据

           1. 创建hive avro文件格式表

        CREATE TABLE test_avro

        ROW FORMAT

        SERDE 'org.apache.hadoop.hive.serde2.avro.AvroSerDe'

        STORED AS

        INPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat'

        OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat'

        TBLPROPERTIES ('avro.schema.literal'='{  

        "namespace": "testing.hive.avro.serde",  

        "name": "test_avro",  

        "type": "record",  

        "fields": [   

{ "name":"a",      

        "type":"string",      

        "doc":"test a"},    

        {  "name":"b",      

        "type":"string",      

        "doc":"test b"},    

        {"name":"c",      

        "type":"string",      

        "doc":"test c"},    

        {"name":"x",      

        "type":"string",      

        "doc":"test d"},

        {"name":"y",      

        "type":"string",      

        "doc:":"test e",      

        "default":"fishfingers and custard" } 

]}');

2. hbase导入到hive:

           insert overwrite table test_avro select * from test_sqoop;

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值