sqoop import --connect jdbc:mysql://localhost:3306/test1 --username root --password root --table article --hive-import --hive-table testERROR tool.ImportTool: Encountered IOException running import job: org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory hdfs://hadoopMaster:9000/user/hadoop/article already exists at org.apache.hadoop.mapreduce.lib.output.FileOutputFormat.checkOutputSpecs(FileOutputFormat.java:164) at org.apache.hadoop.mapreduce.JobSubmitter.checkSpecs(JobSu
时间: 2023-10-09 13:12:03 浏览: 44
这个错误提示是因为你指定的 HDFS 输出路径已经存在,而 Sqoop 默认不允许覆盖已经存在的目录。你可以尝试在 `--hive-table` 参数后面添加 `--hive-overwrite` 参数,让 Sqoop 覆盖已经存在的 Hive 表。
命令示例:
```
sqoop import --connect jdbc:mysql://localhost:3306/test1 --username root --password root --table article --hive-import --hive-table test --hive-overwrite
```
如果这样仍然不能解决问题,你可以尝试删除已经存在的 HDFS 目录,或者修改输出路径。
相关问题
sqoop import --connect jdbc:mysql://localhost:3306/test1 --username root --password root --table article --hive-import --hive-table testERROR tool.ImportTool: Encountered IOException running import job: org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory hdfs://hadoopMaster:9000/user/hadoop/article already exists at org.apache.hadoop.mapreduce.lib.output.FileOutputFormat.checkOutputSpecs(FileOutputFormat.java:164) at org.apache.hadoop.mapreduce.JobSubmitter.checkSpecs(JobSu修改输出路径
可以在命令后面添加`--delete-target-dir`参数来删除已经存在的目录,如下所示:
```
sqoop import --connect jdbc:mysql://localhost:3306/test1 --username root --password root --table article --hive-import --hive-table test --delete-target-dir
```
这样就会在导入数据前将已经存在的输出目录删除。如果你想保留原有的输出目录,可以手动将其删除,或者修改输出路径,如下所示:
```
sqoop import --connect jdbc:mysql://localhost:3306/test1 --username root --password root --table article --hive-import --hive-table test --target-dir /user/hadoop/article_new
```
这样就会将数据导入到新的输出目录`/user/hadoop/article_new`中。
sqoop import --connect jdbc:mysql://localhost:3306/test1 --username hive --password hive --table user --hive-import --hive-table user
这是一个用于将 MySQL 数据库中的表导入到 Hive 中的 Sqoop 命令。具体来说:
- `sqoop import` 表示要执行 Sqoop 的导入操作。
- `--connect jdbc:mysql://localhost:3306/test1` 指定了要连接的 MySQL 数据库的地址和端口。
- `--username hive --password hive` 指定了连接 MySQL 数据库所需的用户名和密码。
- `--table user` 指定了要导入的 MySQL 数据库中的表名。
- `--hive-import` 表示要将数据导入到 Hive 中。
- `--hive-table user` 指定了要将数据导入到 Hive 中的表名。
因此,执行这个命令可以将 MySQL 数据库中的 user 表导入到 Hive 中的 user 表中。