用sqoop將mysql的資料匯入到hive表

來源:互聯網
上載者:User

標籤:res   int   lis   address   char   class   nbsp   hdfs   --   

一、先將mysql一張表的資料用sqoop匯入到hdfs

1.1、先在mysql中準備一張測試用的表

mysql> desc user_info;+-----------+-------------+------+-----+---------+-------+| Field     | Type        | Null | Key | Default | Extra |+-----------+-------------+------+-----+---------+-------+| id        | int(11)     | YES  |     | NULL    |       || user_name | varchar(50) | YES  |     | NULL    |       || age       | int(11)     | YES  |     | NULL    |       || address   | varchar(50) | YES  |     | NULL    |       |+-----------+-------------+------+-----+---------+-------+4 rows in set (0.14 sec)mysql> select * from user_info;+------+-----------+------+--------------------+| id   | user_name | age  | address            |+------+-----------+------+--------------------+|    1 | zhangsan  |   20 | shenzhen nanshang  ||    2 | lisi      |   20 | shenzhen futian    ||    3 | wangwu    |   23 | shenzhen luohu     ||    4 | cailiu    |   24 | shenzhen guangming ||    5 | zhuqi     |   25 | shenzhen baoan     ||    6 | houba     |   26 | shenzhen xili      ||    7 | laojiu    |   27 | shenzhen yantian   |+------+-----------+------+--------------------+7 rows in set (0.00 sec)mysql> 

下面 將 user_info表中的前100條資料導 匯出來  只要id  user_name和 age 這3個欄位,資料存在hdfs 目錄 /tmp/sqoop/user_info下。

 

用sqoop將mysql的資料匯入到hive表

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.