------------导出 export---- allowinsert updateonly ---------------------------
[root@gree139 tmp]# vi ./teacher.txt
1,gree,jy,dsj
2,cat,leader,dsj
[root@gree139 tmp]# hdfs dfs -put ./teacher.txt /sqoop/exportdata/
[root@gree139 tmp]# sqoop export \
--connect jdbc:mysql://gree139:3306/mybatisdb \
--username root \
--password root \
--table teacher \
--export-dir /sqoop/exportdata/ \
--update-key id \
--update-mode allowinsert
[root@gree139 tmp]# sqoop export \
--connect jdbc:mysql://gree139:3306/mybatisdb \
--username root \
--password root \
--table teacher \
--export-dir /sqoop/exportdata2/ \
--update-key id \
--update-mode updateonly
[root@gree139 tmp]# sqoop export \
--connect jdbc:mysql://gree139:3306/mybatisdb \
--username root \
--password root \
--table teacher \
--export-dir /sqoop/exportdata3/ \
--update-key id \
--update-mode allowinsert
-----------job --------------------------------
sqoop job --create demojob -- import \
--connect jdbc:mysql://gree139:3306/mybatisdb \
--username root \
--password root \
--table student \
--delete-target-dir \
--target-dir /sqoop/job/ \
--m 1
[root@gree139 tmp]# sqoop job --list
[root@gree139 tmp]# sqoop job --exec demojob
[root@gree139 tmp]# sqoop job --delete demojob
[root@gree139 tmp]# sqoop job --show demojob
[root@gree139 tmp]# crontab -e
*/10 * * * * /opt/soft/sqoop146/bin/sqoop job --exec demojob
---------job 免密执行----------------------------------
[root@gree139 tmp]# vi /opt/soft/sqoop146/conf/sqoop-site.xml
<property>
<name>sqoop.metastore.client.record.password</name>
<value>true</value>
<description>If true, allow saved passwords in the metastore.</description>
</property>
echo -n "root" > mysqlpwd.pwd 将密码输出到mysqlpwd.pwd文件中
hdfs dfs -put ./mysqlpwd.pwd /mysql/
hdfs dfs -chmod 400 /mysql/mysqlpwd.pwd
sqoop job --create demojobmm -- import \
--connect jdbc:mysql://gree139:3306/mybatisdb \
--username root \
--password-file /mysql/mysqlpwd.pwd \
--table student \
--delete-target-dir \
--target-dir /sqoop/job2/ \
--m 1
sqoop job --exec demojobmm
版权声明:本文为liuyongsheng666原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。