2023-06-06 18:10:33,041 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7 2023-06-06 18:10:33,075 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead. 2023-06-06 18:10:33,218 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset. 2023-06-06 18:10:33,218 INFO tool.CodeGenTool: Beginning code generation Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. 2023-06-06 18:10:33,782 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `user_log` AS t LIMIT 1 2023-06-06 18:10:33,825 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `user_log` AS t LIMIT 1 2023-06-06 18:10:33,834 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /opt/module/hadoop-3.1.4 注: /tmp/sqoop-root/compile/5f4cfb16d119de74d33f1a0d776d5ae0/user_log.java使用或覆盖了已过时的 API。 注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。 2023-06-06 18:10:35,111 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-root/compile/5f4cfb16d119de74d33f1a0d776d5ae0/user_log.jar 2023-06-06 18:10:35,125 WARN manager.MySQLManager: It looks like you are importing from mysql. 2023-06-06 18:10:35,126 WARN manager.MySQLManager: This transfer can be faster! Use the --direct 2023-06-06 18:10:35,126 WARN manager.MySQLManager: option to exercise a MySQL-specific fast path. 2023-06-06 18:10:35,126 INFO manager.MySQLManager: Setting zero DATETIME behavior to convertToNull (mysql) 2023-06-06 18:10:35,130 ERROR tool.ImportTool: Import failed: No primary key could be found for table user_log. Please specify one with --split-by or perform a sequential import with '-m 1'.
时间: 2024-03-10 16:45:04 浏览: 176
sqoop-1.4.7.bin-hadoop-2.6.0
这个错误提示表示Sqoop在导入数据时无法确定一个主键用于分片数据。这可能是由于你导入的表没有主键或你没有指定分片列导致的。
你可以尝试使用--split-by参数指定一个用于分片的列,或者使用-m 1参数指定只使用一个Mapper来导入数据。具体的命令如下:
1. 使用--split-by参数指定分片列:
```
sqoop import --connect jdbc:mysql://localhost:3306/mydatabase \
--username myuser --password mypassword \
--table user_log \
--split-by id
```
其中,id为你指定的分片列。
2. 使用-m 1参数只使用一个Mapper导入数据:
```
sqoop import --connect jdbc:mysql://localhost:3306/mydatabase \
--username myuser --password mypassword \
--table user_log \
-m 1
```
这样可以保证在导入数据时只使用一个Mapper,避免分片问题。但是,如果数据量很大,可能会导致导入速度变慢。
阅读全文