HDFS、Hive、MySQL、Sqoop之間的資料匯入匯出(強烈建議去看)

來源:互聯網
上載者:User

標籤:匯出   .net   size   資料轉換   ref   dir   username   nat   tmp   

Hive總結(七)Hive四種資料匯入方式 (強烈建議去看)

Hive幾種資料匯出方式 https://www.iteblog.com/archives/955 (強烈建議去看)

 

 

 

 

把MySQL裡的資料匯入到HDFS

  1、使用MySQL工具手工匯入

  把MySQL的匯出資料匯入到HDFS的最簡單方法就是,使用命令列工具和MySQL語句。

為了匯出整個資料表或整個資料庫的內容,MySQL提供了mysqldump工具。

 

  比如

  SELECT  col1,col2 FORM TABLE 

      INTO OUTFILE ‘/tmp/out.csv‘

  FIELDS TERMINATED BY ‘,‘ , LINES  TERMINATED  BY ‘\n‘;

  這個學格式就好,具體表看自己的。

  一旦我們把資料匯出到檔案中,就可以用hadoop fs -put把該檔案,從本地linux移到HDFS上。

 

  2、使用Sqoop把MySQL裡的資料匯入到HDFS

  $ sqoop  import  --connect  jdbc:mysql://192.168.80.128/hive  --username   hive   \ >  --password  hive   --table  employees

  注意,這雷根據自己的來,中繼資料庫名,使用者名稱和密碼

 

 

 

 

把MySQL裡的資料匯入到Hive

  $ sqoop  import  --connect jdbc:mysql://192.168.80.128/hive   --username  hive   -password  hive  --table employees   --hive-import    --hive-table  employees

  更為詳細,見

用Sqoop將mysql中的表和資料匯入到Hive中

 

 

 

 

 

把HDFS裡的資料匯出到MySQL

  $ sqoop  export --connect  jdbc:mysql://192.168.80.128/hive  --username  hive   -password  hive  --table employees   --export-dir  edata  --input-fields-terminated-by  ‘\t‘

  更為詳細,見

Sqoop1.4.5+hadoop2.2.0進行Mysql到HDFS的資料轉換

 

 

 

 

 

把HDFS裡的資料匯出到Hive

 $  sqoop  export  --connect jdbc://mysql://192.168.80.128/hive  -username  hive   -password  hive  --table employees  --export-dir  /user/hive/warehouse/employees   --input-fields-terminated-by  ‘\001‘     --input-lines-terminated-by  ‘\n‘ 

HDFS、Hive、MySQL、Sqoop之間的資料匯入匯出(強烈建議去看)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.