进入cdh集群sqoop配置管理界面
找到
sqoop-conf/sqoop-site.xml 的 Sqoop 1 Client 客户端高级配置代码段(安全阀)
配置选择xml配置
新增
<property>
<name>sqoop.metastore.client.enable.autoconnect</name>
<value>true</value>
<description>If true, Sqoop will connect to a local metastore for job management when no other metastore arguments are provided.</description>
</property><property>
<name>sqoop.metastore.client.autoconnect.url</name>
<value>jdbc:mysql://data1:3306/sqoop?createDatabaseIfNotExist=true</value>
</property><property>
<name>sqoop.metastore.client.autoconnect.username</name>
<value>root</value>
</property><property>
<name>sqoop.metastore.client.autoconnect.password</name>
<value>password</value>
</property>
5.创建增量同步任务
sqoop job --create task_name \
-- import --connect 'jdbc:mysql://data2:3306/xxx?rewriteBatchedStatements=true&autoReconnect=true&useSSL=false' \
--username root --password-file /user/hdfs/password \
--query "select * from tb where \$CONDITIONS" \
--split-by id \
--fields-terminated-by '\01' \
--lines-terminated-by '\n' \
--target-dir "/sqoop/tb/" -m 1 \
--hive-delims-replacement ' ' \
--incremental append \
--check-column id \
--last-value 0
- 在集群任意机器执行任务
sqoop job --exec task_name