Use of Sqoop

Source: Internet
Author: User
Tags sqoop

Sqoop installation: Installed on a node on the can.

1. Upload Sqoop

2. Install and configure add SQOOP to environment variable copy the database connection driver to $sqoop_home/lib 3. Use the first class: Data in the database is imported into HDFs SQOOP import--connect jdbc:mysql://192.16 8.1.10:3306/itcast--username root--password 123--table trade_detail--columns ' ID, account, income, expenses ' Specify the output Out path, specified data delimiter sqoop import--connect jdbc:mysql://192.168.1.10:3306/itcast--username root--password 123--table trade_d Etail--target-dir '/sqoop/td '--fields-terminated-by ' \ t ' specify map number-m sqoop import--connect jdbc:mysql://192.168.1 .10:3306/itcast--username Root--password 123--table trade_detail--target-dir '/sqoop/td1 '--fields-terminated-by ' \ t '-M 2

   Add where condition, note: The condition must be enclosed in quotation marks   sqoop import--connect jdbc:mysql://192.168.1.10:3306/itcast-- Username root--password 123 --table trade_detail--where ' id>3 '--target-dir '/sqoop/td2 '

   Add a query statement (use \ Wrap statement)   sqoop import--connect jdbc:mysql://192.168.1.10:3306/itcast--username Root--password 123 \--query ' SELECT * from Trade_detail where ID > 2 and $CONDITIONS '--split-by trade_detail.id--ta Rget-dir '/sqoop/td3 '       Note: If you use the--query command, you need to be aware of the arguments behind the where, and $CONDITIONS This parameter must be added    There is the difference between single and double quotes, if--query is followed by double quotes, you need to precede $conditions with \ \ $CONDITIONS    If you set the number of maps to 1-m 1, do not add--split-by ${tablename.column}, or you need to add      Second class: The data on HDFs is exported to the database (do not forget to specify the delimiter)   sqoop Export--connect jdbc:mysql://192.168.8.120:3306/itcast--username root--password 123--export-dir '/td3 '--table td_ Bak-m 1--fields-terminated-by ', '   4. Configure MySQL remote connection  grant all privileges on itcast.* to ' root ' @ ' 192.168.1.201 ' Identified by ' 123 ' with GRANT OPTION;  flush privileges;    grant all privileges on * * to ' root ' @ '% ' identified by ' 123 ' with GRANT OPTION;  flush Privileges  

Use of Sqoop

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.