sqoop hbase導入並與hive結合

sqoop語句
以tid爲主鍵,info爲列族
Html代碼 複製代碼 收藏代碼
  1. sqoop import --connect jdbc:mysql://ip/taobao_db --username hive --password 123456 --table mysql_table_name --hbase-table hbase_table_name --column-family info --split-by tid 
sqoop import --connect jdbc:mysql://ip/taobao_db --username hive --password 123456 --table mysql_table_name --hbase-table hbase_table_name --column-family info --split-by tid


hbae創建表語句
Sql代碼 複製代碼 收藏代碼
  1. create 'trade','info' 
create 'trade','info'


hive創建表語句
Sql代碼 複製代碼 收藏代碼
  1. CREATE EXTERNAL TABLE hbase_trade( 
  2. tid string, 
  3. dp_id string, 
  4. created string, 
  5. modified string, 
  6. buyer_cod_fee double,)  
  7. STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 
  8. WITH SERDEPROPERTIES ("hbase.columns.mapping" = "info:dp_id,info:created,info:modified,info:buyer_cod_fee") TBLPROPERTIES("hbase.table.name" = "hbase_table_name"); 
CREATE EXTERNAL TABLE hbase_trade(
tid string,
dp_id string,
created string,
modified string,
buyer_cod_fee double,) 
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = "info:dp_id,info:created,info:modified,info:buyer_cod_fee") TBLPROPERTIES("hbase.table.name" = "hbase_table_name");

遺留問題
sqoop導入數據至hbase時,split-by字段只能是一個,處理不了多字段聯合主鍵的情況。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章