Sqoop exporting from HDFs to MySQL

Source: Internet
Author: User
Tags sqoop

Create database logs;

Use logs

CREATE TABLE Weblogs_from_hdfs (
MD5 varchar (32),
URL varchar (64),
Request_date date,
Request_time time,
IP varchar (15)
);

Sqoop export-m 1--connect jdbc:mysql://hadoop:3306/logs--username root--password root--table weblogs_from_hdfs--expo Rt-dir/data/weblogs/import--input-fields-terminated-by ' \ t '
Null for data imported through Sqoop, which remains null when exported to the database. Even if the file is saved as a string of ' null '.
Sqoop inserts a new statement by default for insert
--update-key ' MD5 ' will create an UPDATE statement, update .... where MD5 = ' ... '
If the value set by--update-key ' MD5 ' is not found, you can set the--update-mode Allowinsert allow this line of data to be added

Each mapper by default inserts 1000 records, and then commits the transaction, if Mapper fails, there may be insert conflict or insert duplicate data, can be--staging-table temptablename through a temporary table, Wait for a transaction to complete before copying the data into the table specified by--table, the temporary table structure must be consistent with the final table
CREATE TABLE temp_table as SELECT * from real_table where 1=0;
Temporary table must be empty table, no side must configure parameter--clear-staging-table empty temporary table before inserting data


Related Article

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.