HBase combines hive and sqoop to implement data guidance for MySQL

Source: Internet
Author: User

Hive synthetic hbase Two advantages table: 
1. Implement data import to MySQL.
2. Implement the HBase table into another hbase table.
 


Three operation Links:
1.hbase Associated hive as an external table:
SQL code
  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  ( Span class= "string" style= "Color:blue" > "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 true associated hive,hive Insert update operations directly affect data in HBase
 SQL code
  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  ( Span class= "string" style= "Color:blue" > "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. Create a hive table
SQL code
    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. External table data import into hive real table
   SQL code
    1. Insert overwrite table hive_device_app_real Select * from Hive_device_app

5.sqoop exporting hive data to MySQL
   SQL code
    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 (Associated hive) One table goes to another table of course you can use the built-in functions of hive for data processing
  SQL code
    1. insert  overwrite table  another_hive_hbase_related_table select  *  from  hbase_device_app    



exporting data from HBase to MySQL requires steps: 1345
HBase in one table to another table (in the middle can use hive for data processing of built-in functions): 226
 

HBase combines hive and sqoop to implement data guidance for MySQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.