sqoop

sqoop import

--connect jdbc:mysql://h2:3306/test

--username hive

--password 123456

--table t6

--incremental lastmodified

--check-column last_update

--merge-key address_id

--last-value '2019-05-05 19:43:11'

-m 1

注:incremental:

(1)append

(2)lastmodified:

merger-key(合并相同的merge)

append (追加)

sqoop job 
--create job_address
-- import
--connect jdbc:mysql://h2:3306/test
--username hive
--password-file '/user/grid/passwd.pwd'
--table t6
--incremental lastmodified
--check-column last_update
--merge-key address_id
--last-value '2019-05-05 19:43:11'
-m 1

注:指定
--split-by或者 -m 1

-- import 中间有空格

--password-file 指定集群内文件,作为密码文件

生成方式 例:

echo -n "123456" > passwd.pwd

hdfs dfs -put passwd.pwd /user/grid

hdfs dfs chmod 400 /user/grid/passwd.pwd

sqoop job --help(查看sqoop job常见用法)

sqoop job --create test 
 -- import -Dorg.apache.sqoop.splitter.allow_text_splitter=true
 --connect jdbc:mysql://h2:3306/test 
 --username hive 
 --password-file /user/grid/jobaddress.pwd 
 --query 'select address_id, address,last_update from t6 where $CONDITIONS and address_id>1' 
 --target-dir '/user/grid/' 
 --incremental lastmodified 
 --check-column last_update 
 --merge-key address_id 
 --last-value '2019-05-05 19:43:11' 
 --split-by address 

注:这种写法报错,在使用job时,如何指定split 列(text类型)

和crontab组合,做定时job

原文地址:https://www.cnblogs.com/jy627625/p/10817768.html