Sqoop导入失败

时间:2016-10-24 18:59:29

标签: sqoop

我正在尝试使用Sqoop将表从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

所以我在许多论坛上在线阅读,它说我应该删除目录并再次运行命令。 我做到了这一点,但我仍然不断收到错误。

2 个答案:

答案 0 :(得分:2)

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

  • 将数据导入HDFS <some-dir>
  • 创建配置表<some-table>如果不存在
  • 将路径“<some-dir>”中的数据加载到表<some-table>

您在第1步收到错误。

Output directory <hdfs path> already exists

删除此<hdfs path>并继续。

更好的方式:

无需每次都手动删除。

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

  

删除导入目标目录(如果存在)

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

答案 1 :(得分:0)

Hive将表数据存储在hdfs的hive仓库中,表名为目录,通常位于路径下方

<强> /用户/蜂巢/仓库/

需要删除表名目录。

hadoop fs -rmr /user/hive/warehouse/hive_test
相关问题