使用Sqoop从PostgreSQL向Hive中迁移数据遇到的问题

postgreSQL的界面

使用Sqoop从PostgreSQL向Hive中迁移数据遇到的问题

跟mysql不同之处就是,多了一个 2 ,这也是导致数据迁移错误原因

1.数据库名称   2.schema  3.表名

PostgreSQL中的对象属于三层模型,即database->schema->table。PostgreSQL中一般包含多个database,每个database包含多个schema,schema下包含多个表。因此使用sqoop抽取数据时有时需要指定表是属于哪个schema。

解决方案:在代码最后指定--schema

-- --schema 上图2的名称

整个代码如下

./sqoop import --connect jdbc:postgresql://192.168.***.***:38888/bigdata --username postgres --password password --table tb_ecar_gps_zhengzhou_standard  --fields-terminated-by '\t' -m 1 --target-dir '/sqoop/postgresql123' -- --schema benchmark_data;

参考文章:https://blog.csdn.net/Post_Yuan/article/details/79799980