Installed on a single node is available.
1. Upload Sqoop using WINSCP
2. Installation and Configuration
Add Sqoop to environment variable
Copy the database connection driver Mysql-connector-5.1.8.jar to the $sqoop_home/lib
### First class: Data in the database is imported into HDFs
Sqoop Import--connect jdbc:mysql://192.168.1.10:3306/itcast--username root--password 123--table Trade_detail--colum NS ' ID, account, income, expenses '
Specify the output path, specify the data delimiter
Sqoop Import--connect jdbc:mysql://192.168.1.10:3306/itcast--username root--password 123--table Trade_detail--targe T-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--targe T-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--target-dir '/sqoop/td3 '
Note: If you use the--query command, it is important to note that the argument after the where, and $CONDITIONS This parameter must be added
And there is the difference between single and double quotes, if--query is followed by double quotes, then you need to add \ \ \ $CONDITIONS
If you set the number of maps to 1---M 1, without adding--split-by ${tablename.column}, you need to add a
### Type II: Export data from HDFs to the database (do not forget to specify delimiters)
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 ', '
Three. Configure MySQL remote connection
GRANT all privileges the 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
Hadoop (eight)-Sqoop installation and use