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