zoukankan      html  css  js  c++  java
  • hive与hbase集成

    环境:

    hadoop2.7.7

    hive3.1.0

    hbase2.0.2

    1.jar包拷贝(之所以用这种方式,是因为这种方式最为稳妥,最开始用的软连接的方式,总是却少jar包)到hive的lib目录下删除所有hbase相关的jar

    rm -rf hbase-*.jar

    接着从hbase的lib目录下拷贝所有的hbase相关jar

    cp -a  hbasehome/lib/hbase-*.jar ./

    zookeeper相关的jar也要进行替换

    2.在hive的hive-site.xml中添加zk的相关配置

     1  <property>
     2   <name>hive.zookeeper.quorum</name>
     3   <value>hadoop002,hadoop003,hadoop004</value>
     4   <description>The list of ZooKeeper servers to talk to. This is only needed for read/write locks.</description>
     5 </property>
     6 <property>
     7   <name>hive.zookeeper.client.port</name>
     8   <value>2181</value>
     9   <description>The port of ZooKeeper servers to talk to. This is only needed for read/write locks.</description>
    10 </property>

    3.在hive中创建表,执行完建表语句后,会在hbase生成对应的hbase_emp_table表,但是这种表是non-native table类型的表,无法被truncate,也无法使用load加载数据

     1 CREATE TABLE hive_hbase_emp_table(
     2 empno int,
     3 ename string,
     4 job string,
     5 mgr int,
     6 hiredate string,
     7 sal double,
     8 comm double,
     9 deptno int)
    10 STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
    11 WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,info:ename,info:job,info:mgr,info:hiredate,info:sal,info:comm,info:deptno")
    12 TBLPROPERTIES ("hbase.table.name" = "hbase_emp_table");

    4.插入数据

    上面说了无法通过load加载数据,所以借助临时表进行insert,已提前创建了emp表.并插入了数据

    empno对应hbase_emp_table的行键,不能为null

    insert into table hive_hbase_emp_table select * from emp where empno is not null;

    5.之后分别在hive和hbase查询数据即可

    6.无法创建新的管理表与hbase_emp_table关联,只能通过创建外部表的方式与hbase_emp_table进行关联

  • 相关阅读:
    Codeforces369E Valera and Queries
    Codeforces369C Valera and Elections
    笔记 navmesh
    笔记 fastbuild
    C++ 遍历某个文件夹下所有文件
    ACM 已结束
    2018 “百度之星”程序设计大赛
    2018 Multi-University Training Contest 1 1002 /hdu6299 贪心 1007 /hdu6304 找规律
    2018 Multi-University Training Contest 5 1008 / hdu6357 Hills And Valleys LCS,思维
    牛客网暑期ACM多校训练营(第二场)G transform 思维,二分
  • 原文地址:https://www.cnblogs.com/tele-share/p/9984903.html
Copyright © 2011-2022 走看看