zoukankan      html  css  js  c++  java
  • hbase结合hive和sqoop实现数据指导mysql

    hive综合hbase两个优势表中的: 
       1.实现数据导入到MYSQL。 
       2.实现hbase表转换为另外一张hbase表。
     


    三个操作环节: 
        1.hbase关联hive作为外部表: 
    Sql代码  收藏代码
    1. CREATE EXTERNAL TABLE hive_device_app(row_key string,genera_type string,install_type string,label string,meid string,model string,pkg_name string,specific_type string)   
    2. STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'   
    3. WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf:genera_type,cf:install_type,cf:label,cf:meid,cf:model,cf:pkg_name,cf:specific_type")   
    4. TBLPROPERTIES("hbase.table.name" = "tb_yl_device_app_info1");  


       2.hbase真正关联hive,hive的插入更新等操作直接影响hbase中的数据 
     
    Sql代码  收藏代码
    1. CREATE  TABLE hbase_device_app(row_key string,genera_type string,install_type string,label string,meid string,model string,pkg_name string,specific_type string)   
    2. STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'   
    3. WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf:genera_type,cf:install_type,cf:label,cf:meid,cf:model,cf:pkg_name,cf:specific_type")   
    4. TBLPROPERTIES("hbase.table.name" = "tb_yl_device_app_info2");  

       
       3.创建一张hive表 
    Sql代码  收藏代码
    1. CREATE TABLE hive_device_app_real(row_key string,genera_type string,install_type string,label string,meid string,model string,pkg_name string,specific_type string)   


       4.外部表数据导入hive实表 
       
    Sql代码  收藏代码
    1. insert overwrite table hive_device_app_real select * from hive_device_app   

        5.sqoop导出hive的数据到mysql 
       
    Sql代码  收藏代码
    1. sqoop export --connect jdbc:mysql://Hadoop48/toplists -m 1 --table hive_device_app_real --export-dir /user/hive/warehouse/hive_device_app_real/000000_0 --input-null-string "\\N" --input-null-non-string "\\N" --input-fields-terminated-by "\01" --input-lines-terminated-by "\n"  

        
       6.habse(关联hive)中一张表转到另外一张表当然能够利用hive的内置函数实现数据处理 
      
    Sql代码  收藏代码
    1. insert overwrite table another_hive_hbase_related_table select * from hbase_device_app   



    导出hbase中数据到mysql须要经过步骤:1345 
    hbase在一个表到另一个表(中间可以使用hive用于数据处理的内置函数):226
     
  • 相关阅读:
    InnoDB 事务隔离级探索
    套接字 缓冲区 6次拷贝 内核协议栈
    Python Data Structure and Algorithms Tutorial
    任何Python线程执行前,必须先获得GIL锁,然后,每执行100条字节码,解释器就自动释放GIL锁,让别的线程有机会执行
    Linux网络状态工具ss命令使用详解
    不占用额外内存空间能否做到 将图像旋转90度 N × N矩阵表示的图像,其中每个像素的大小为4字节
    尾递归 栈溢出
    t
    t
    __del__ PyPy和CPython的不同点 动态编译(注意不是解释) 析构函数被调用的次数
  • 原文地址:https://www.cnblogs.com/gcczhongduan/p/4741607.html
Copyright © 2011-2022 走看看