Sqoop Common Commands

Source: Internet
Author: User
Tags split mysql import sqoop
Use


1 MySQL import data to HDFs
1.1./sqoop Import--connect jdbc:mysql://192.168.116.132:3306/sqoop--username root--password 123456--table test_user --target-dir/sqoop/test_user-m 2--fields-terminated-by "\ T"--columns "id,name"--where ' id>2 and Id<=6 '

--connect Connection Database
--username Users
--password Password
--table Table Name
--target-dir Target directory/sqoop/test_user
-M 2 mapreduce execution
--fields-terminated-by use "\ T" to separate the comma by default.
--columns only import ID and name two fields
--where Adding conditional filter statements to be held in quotation marks.



1.2./sqoop Import--connect jdbc:mysql://192.168.116.132:3306/sqoop--username root--password 123456--query ' SELECT * From Test_user where ID < 9 and ID > 1 and $CONDITIONS '--target-dir/sqoop/test_user4-m 2--split-by test_user.id

--query directly with query statements so that joins can query multiple tables
-M 1 can be executed greater than 1 if you want multiple maps to set how much data each map reads, separated by--split-by
--split-by test_user.id


2.hdfs data export to MySQL

2.1./sqoop export--connect jdbc:mysql://192.168.116.132:3306/sqoop--username root--password 123456--export-dir '/ Sqoop/test_user5 '--table test_user-m 2

--export-dir the directory that needs to be exported/sqoop/test_user5


3.mysql Import into Hive
./sqoop Import--hive-import--connect jdbc:mysql://192.168.116.132:3306/sqoop--username root--password 123456-- Table Test_user-m 2--hive-table Hive_user

--hive-import specifying import into Hive
--hive-table Import to a table in hive hive_user if no table is created automatically

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.