将数据从 redshift 传输到 postgresql

LKk*_*LKk 2 migration postgresql data-transfer amazon-web-services amazon-redshift

我尝试寻找但找不到

将数据从 Redshift 复制到 Postgresql 数据库的最佳方法是什么?

使用 Talend 作业/任何其他工具/代码等

无论如何,我也想将数据从 Redshift 传输到 PostgreSQL 数据库,您可以使用任何具有类似功能的第三方数据库工具。

另外,据我所知,我们可以使用 AWS Data Migration Service来执行此操作,但不确定我们的源数据库和目标数据库是否符合该条件

谁能建议更好的东西吗?

Jon*_*ott 7

我的方法是使用 Postgres 外部数据包装器和 dblink,

这样,红移表就可以直接在 Postgres 中使用。

按照此处的说明进行设置https://aws.amazon.com/blogs/big-data/join-amazon-redshift-and-amazon-rds-postgresql-with-dblink/

该链接的重要部分是以下代码:

CREATE EXTENSION postgres_fdw;
CREATE EXTENSION dblink;
CREATE SERVER foreign_server
        FOREIGN DATA WRAPPER postgres_fdw
        OPTIONS (host '<amazon_redshift _ip>', port '<port>', dbname '<database_name>', sslmode 'require');
CREATE USER MAPPING FOR <rds_postgresql_username>
        SERVER foreign_server
        OPTIONS (user '<amazon_redshift_username>', password '<password>');
Run Code Online (Sandbox Code Playgroud)

对于我的用例,我设置了一个 postgres 物化视图,并基于此建立了索引。

create materialized view if not exists your_new_view as
SELECT some,
       columns,
       etc
   FROM dblink('foreign_server'::text, '
<the redshift sql>
'::text) t1(some bigint, columns bigint, etc character varying(50));

create unique index if not exists index1
    on your_new_view (some);

create index if not exists index2
    on your_new_view (columns);
Run Code Online (Sandbox Code Playgroud)

然后我定期运行(在 postgres 上)

REFRESH MATERIALIZED VIEW your_new_view;
Run Code Online (Sandbox Code Playgroud)

或者

REFRESH MATERIALIZED VIEW CONCURRENTLY your_new_view;
Run Code Online (Sandbox Code Playgroud)