sqoop增量import:import failed当使用--incremental lastmodified并且输出目录存在时,需要--merge key或--append

nkkqxpd9  于 2021-06-03  发布在  Sqoop
关注(0)|答案(1)|浏览(437)

我已经使用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.
8nuwlpux

8nuwlpux1#

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

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

相关问题