Sqoop 导入失败

Sqoop Import Fails

我正在尝试使用 Sqoop 将 Table 从 Oracle 导入到 Hive。我使用了以下命令:

sqoop-import --connect jdbc:<connection> --table test1 --username test --password test --hive-table hive_test --create-hive-table --hive-import -m 1    

但这给了我错误

 Encountered IOException running import job: org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory <hdfs path> already exists

所以网上看了很多论坛都说要删除目录,再运行命令。 我正是这样做的,但我仍然不断收到错误消息。

您需要了解 Sqoop hive Import 的工作原理。

  • 将数据导入 HDFS <some-dir>
  • 创建配置单元 table <some-table> IF NOT EXISTS
  • 将路径“<some-dir>”中的数据加载到 table <some-table>

您在第 1 步遇到错误。

Output directory <hdfs path> already exists

删除此 <hdfs path> 并继续。

更好的方法:

不需要每次都手动删除。

在命令中使用--delete-target-dir。会

Delete the import target directory if it exists

P.S. 无需将 --create-hive-table--hive-import 一起使用。 --hive-import 默认为您创建 table。

Hive 将其 Table 数据存储在 hdfs 上的 hive 仓库中,以 table 名称作为目录,通常具有以下路径

/user/hive/warehouse/

需要删除 table name 目录。

hadoop fs -rmr /user/hive/warehouse/hive_test