使用Sqoop 对 Oracle 做数据迁移 到 PostgreSQL

前端之家收集整理的这篇文章主要介绍了使用Sqoop 对 Oracle 做数据迁移 到 PostgreSQL前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。




基本的流程如上图所示。


前提:


一个可连接的Oracle数据库作为数据源

一个可连接的Postgresql数据库作为目的数据库

一个可使用的Hadoop集群

一个可以用的hive平台


注意事项:

对于将要导入的Oracle的数据库表,我们需要在Postgresql中创建一个字段结构相同的table,此处还需要注意原表是否有主键。



导入命令:

首先查看Oracle中 xe 数据库中的表

./sqoop list-tables --connect jdbc:oracle:thin:@ip:49161:xe --username system --password oracle



然后将其中的一个SALARY表导入hive


./sqoop import --hive-import --connect jdbc:oracle:thin:@ip:xe --username system --password oracle --table SALARY -m 1 --columns 'EMPLOYEEID,INCOME,OUTCOME' --hive-table salary



然后通过hive命令show tables 查看是否存入hive


然后接着查看postgresql中tpcds_1数据库中的所有表



./sqoop list-tables --connect jdbc:postgresql://ip:5432/tpcds_1 --username postgres --password postgres




如果能够正常的显示,接着直接输入命令将 hive 中的表 salary 导入 postgresql


./sqoop export --connect jdbc:postgresql://ip:5432/tpcds_1 --username postgres --password postgres --table salary --fields-terminated-by '\001' --export-dir /user/hive/warehouse/salary/part-m-00000




再去查询一下表内的数据





最后 OK,迁移成功。

原文链接:https://www.f2er.com/oracle/213417.html

猜你在找的Oracle相关文章