sqoop增量导入:导入失败:使用--incremental lastmodified且输出目录存在时,需要--merge-key或--append

时间:2019-06-13 08:34:49

标签: mysql hdfs ubuntu-16.04 sqoop

我已经使用sqoop将mySql数据库表导入到hdfs中。该数据库每天更新。现在,我尝试使用sqoop作为

增量导入数据
sqoop import --connect jdbc:mysql://127.0.0.1/crawl_data_stats --username root --password password --table scraped_comments -m 1 --as-parquetfile --target-dir /databases/crawl_data_stats/scraped_comments --check-column timestamp --incremental lastmodified --last-value '2019-05-16 13:06:31' --driver com.mysql.jdbc.Driver

但是导入失败,并显示以下输出:

19/06/13 12:51:28 INFO manager.SqlManager: Using default fetchSize of 1000  
19/06/13 12:51:28 INFO tool.CodeGenTool: Beginning code generation  
19/06/13 12:51:28 INFO tool.CodeGenTool: Will generate java class as codegen_scraped_comments  
Thu Jun 13 12:51:28 IST 2019 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.  
19/06/13 12:51:29 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM scraped_comments AS t WHERE 1=0  
19/06/13 12:51:29 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM scraped_comments AS t WHERE 1=0  
19/06/13 12:51:29 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /usr/local/hadoop  
Note: /tmp/sqoop-root/compile/8ccf132bb0ce002d14d2afeb75f85cf9/codegen_scraped_comments.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.  
19/06/13 12:51:31 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-root/compile/8ccf132bb0ce002d14d2afeb75f85cf9/codegen_scraped_comments.jar  
19/06/13 12:51:32 ERROR tool.ImportTool: Import failed: --merge-key or --append is required when using --incremental lastmodified and the output directory exists.  

1 个答案:

答案 0 :(得分:1)

在将合并键选项添加到sqoop导入命令时,错误消失了

sqoop import --connect jdbc:mysql://127.0.0.1/crawl_data_stats --username root --password password --table scraped_metadata -m 1 --as-parquetfile --target-dir /databases/crawl_data_stats/scraped_metadata --check-column timestamp --incremental lastmodified --last-value '2019-05-16 13:06:31' --driver com.mysql.jdbc.Driver --merge-key id