Sqoop 1.4.6
Execution method
Sqoop--options-file options1
1.hdfstomysql
export
--connect
jdbc:mysql://bigdatacloud:3306/test
--username
root
-- Password
123
--table
hdfstomysql
--columns id,name,age-
m
1
--export-dir
Hdfs://mycluster/hdfstomysql
2.mysqltohive
Import
--connect
jdbc:mysql://bigdatacloud:3306/test
--username
Root
--password
123
--target-dir
/sqoop/thive
--delete-target-dir
--as-textfile -
m
1
--table
t_p
--columns
id,name,age
--hive-import
--hive-overwrite
--hive-table
T_hive
3.mysqltohdfs
import
--connect
jdbc:mysql://bigdatacloud:3306/test
--username
root
--password
123
--target-dir
/sqoop/t1
--delete-target-dir
-- As-textfile-
m
1
--table
t_p
--columns
id,name,age
1.
Import
--connect
jdbc:mysql://bigdatahadoop:3306/test
--username
root
--password
123456
--table
t_person
--columns
id,name,age
--where 1=1--target-dir
/sqoop/test1
--delete-target-dir
--as-textfile-
m
1
--null-string
'
--null-non-string
'
2
Import
--connect
jdbc:mysql://bigdatacloud:3306/test
--username
root
--password
123456
--query
' Select P.id,name,age,c.card_id,date_format (c.create_date, '%y-%m-%d ') as C_date From T_person P join T_id_card C on p.id=c.p_id where p.age>17 and $CONDITIONS '
--target-dir
/sqoop/test2
--delete-target-dir
--as-textfile-
m
1
--null-string
'
--null-non-string
''
3
Import
--connect
jdbc:mysql://bigdataspark:3306/test
--username
root
--password
123456
--query
' Select P.id,name,age,c.card_id,date_format (c.create_date, '%y-%m-%d ') as C_date from T_person P join T_id_card C on p.id=c.p_id where p.age>17 and $CONDITIONS '
--target-dir
/sqoop/test3
- Delete-target-dir
--as-textfile-
m
1
--null-string
'
--null-non-string
'
--hive-import
--hive-overwrite
--create-hive-table
--hive-table
t_person_card
- -hive-partition-key
Day
--hive-partition-value
' 2016-07-03 '
4
Export
--connect
jdbc:mysql://bigdatacloud:3306/test
--username
root
--password
123456
--table
t_person
--columns
id,name,age-
m
1
--export-dir
hdfs:/ /mycluster/test