问题陈述:确保每个表格文件都分为3个文件,例如part-00000,part-00002,part-00003
sqoop import-all-tables -m 3 --connect jdbc:mysql://localhost/retail_db --username retail_dba --hive-import --hive-overwrite --create-hive-table --compress --compression-codec snappy --outdir java_output
/08/29 02:42:57 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop- training/compile/9cf789b552995b98bd700d07f4cb3de2/categories.jar
16/08/29 02:42:57 WARN manager.MySQLManager: It looks like you are importing from mysql.
16/08/29 02:42:57 WARN manager.MySQLManager: This transfer can be faster! Use the --direct
16/08/29 02:42:57 WARN manager.MySQLManager: option to exercise a MySQL-specific fast path.
16/08/29 02:42:57 INFO manager.MySQLManager: Setting zero DATETIME behavior to convertToNull (mysql)
16/08/29 02:42:57 ERROR tool.ImportAllTablesTool: Error during import: No primary key could be found for table categories. Please specify one with --split-by or perform a sequential import with '-m 1'.
答案 0 :(得分:0)
根据Sqoop docs,
要使import-all-tables工具有用,必须满足以下条件:
- 每个表必须具有单列主键或必须使用
--autoreset-to-one-mapper
选项。
现在根据您的日志,categories
表没有主键。
因此,您需要在sqoop命令中添加--autoreset-to-one-mapper
,以便对于没有主键的表,它使用1个映射器。