简体   繁体   English

无法让 dblink 在只读副本上工作

[英]Unable to get dblink to work on read replica

We have 2 databases on AWS RDS, OMS and SFMS , with each database having its own read replica.我们在 AWS RDS、 OMSSFMS上有 2 个数据库,每个数据库都有自己的只读副本。 We use dblink in SFMS to fetch data of Table A from OMS .我们在SFMS 中使用dblinkOMS获取表 A 的数据。 It works perfectly on my SFMS db instance with Master role, but get an ERROR: could not establish connection on our read replica DB.它在我的具有Master角色的 SFMS 数据库实例上完美运行,但得到一个ERROR: could not establish connection在我们的只读副本数据库上ERROR: could not establish connection

Here is how I have setup the dblink:这是我设置dblink的方法:

SELECT * FROM dblink( 'dbname=<DB End Point> user=<username> password=<password>', 'SELECT id, <Other fields> from A') AS oms_A (id int, <Remaining Schema>)

I can always create a materialized view on SFMS to get it to work.我总是可以在SFMS上创建一个物化视图来让它工作。 Is their some mistake that I am making while setting up DBLink to use it on a read replica instance?我在设置 DBLink 以在只读副本实例上使用它时犯了一些错误吗?

This works on Aiven's PostgreSQL service.这适用于 Aiven 的 PostgreSQL 服务。 Please checkout aiven.io.请查看 aiven.io。

To set it up you first need to create the extension on the master server with 'CREATE EXTENSION dblink;'要进行设置,您首先需要使用“CREATE EXTENSION dblink;”在主服务器上创建扩展。

The foreign server definitions and user name mappings also have to be created on the master which will then replicate them to the read-only replicas.外部服务器定义和用户名映射也必须在主服务器上创建,然后将它们复制到只读副本。

Once those are setup you can do things like: SELECT dblink_connect('myconn', 'db2remote');设置完成后,您可以执行以下操作: SELECT dblink_connect('myconn', 'db2remote'); and SELECT * FROM dblink('myconn','SELECT * FROM foo') AS t(id int);和 SELECT * FROM dblink('myconn','SELECT * FROM foo') AS t(id int); on the read-replica.在只读副本上。

Hope this helps.希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM