zoukankan      html  css  js  c++  java
  • Hive HBase Integration 集成

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

    1、在hive/lib目录下找到hive-hbase-handler-1.2.1.jar,并把该文件拷贝到hbase/lib目录下。

    2、把hbase/lib目录下的所有*.jar文件拷贝到hive/lib目录下。

    3、在hive的配置文件中 hive-site.xml 增加zookeeper的配置集群信息。

    1 <property>
    2         <name>hbase.zookeeper.quorum</name>
    3         <value>node1,node2,node3</value>
    4 </property>

    4、在hive中创建临时表:

    1 CREATE TABLE t_test1 
    2 (id int,name string, age string)  
    3 STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'  
    4 WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,info:name,info:age")  
    5 TBLPROPERTIES ("hbase.table.name" = "t_test1","hbase.mapred.output.outputtable" = "t_test1");

    HBase表信息:

    hbase(main):011:0> describe "t_test1"

    测试在hive中插入数据:

    hive> insert into t_test1(id,name,age)values(001, 'zs', 'male');

    在hbase中同样能查到:

    hbase(main):013:0> scan 't_test1'
    ROW COLUMN+CELL
    1 column=info:age, timestamp=1467337507821, value=male
    1 column=info:name, timestamp=1467337507821, value=zs
    1 row(s) in 0.3310 seconds

    在hbase中插入数据:

    hbase(main):015:0> put 't_test1','002','info:age','30'
    0 row(s) in 0.0430 seconds

    在hive中同样能查到:

    hive> select *From t_test1;
    OK
    2 NULL 30
    1 zs male
    Time taken: 0.312 seconds, Fetched: 2 row(s)

    关联已经存在的hbase表,需要使用external外部表;

    应用场景主要针对已经清洗过的数据,放到hbase中,然后通过hql语句根据业务要求将需要的数据提取出来,然后通过sqoop抽取到类似于mysql的数据库中,供展现使用。

  • 相关阅读:
    关于 Blog 修改
    How To Manage StartUp Applications In Ubuntu
    C++11 之for 新解 auto
    How To Install Cacti On Ubuntu 14
    Apache 2 解析html中的php
    Raspberry Pi
    Compiling a kernel module for the raspberry pi 2 via Ubuntu host
    ubuntu 14.04/14.10 iptables 防火墙设置
    ajax概述
    ajax 异步 通信 小例子 servlet与 jsp异步 post方法
  • 原文地址:https://www.cnblogs.com/one--way/p/5638455.html
Copyright © 2011-2022 走看看