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 07:12:03 浏览: 58
可以在命令后面添加`--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 表中。
检查错误sqoop import --connect jdbc:mysql://zhaosai:3306/mydb --username root --password jqe6b6 --table news --target-dir /user/news --fields-terminated-by “;” --hive-import --hive-table news -m 1
在这个命令中,参数 `--fields-terminated-by` 后面的分隔符使用了中文的双引号 `";"`,应该改为英文的双引号 `";"`。即命令应该改为:
```
sqoop import --connect jdbc:mysql://zhaosai:3306/mydb --username root --password jqe6b6 --table news --target-dir /user/news --fields-terminated-by ";" --hive-import --hive-table news -m 1
```
另外,`--hive-table` 指定的表名需要在 Hive 中已经存在。如果不存在,需要先创建。而且,如果 `--hive-import` 指定了,那么 `--target-dir` 就不需要指定了,因为 sqoop 会自动将数据导入到 Hive 的表中。