我有两个Postgres 9.3.5实例在RDS中,都在同一个安全组中,该安全组允许来自安全组内部的所有入站流量和所有出站流量。我正在尝试设置一个数据库,以便通过postgres_fdw从另一个数据库中选择几个表。
我已经创建了服务器 -
create server master
foreign data wrapper postgres_fdw
OPTIONS (dbname 'main',
host 'myinstance.xxxxx.amazonaws.com');
除了必要的用户映射和外部表 -
create foreign table condition_fdw (
cond_id integer,
cond_name text
) server master options(table_name 'condition', schema_name 'data');
然而,一个简单的
select count(*) from condition_fdw
语句给我返回了ERROR: could not connect to server "master"
DETAIL: could not connect to server: Connection timed out
Is the server running on host "myinstance.xxxxxx.amazonaws.com" (xx.xx.xx.xx) and accepting
TCP/IP connections on port 5432?
我可以通过EC2实例上的
psql
连接到这两个数据库。我知道最近RDS没有支持postgres_fdw,但我正在运行较新的版本,它们支持。在创建服务器语句中,我尝试使用IP地址替换"myinstance.xxxxxx.amazonaws.com",但没有成功。有什么想法吗?进一步测试:
我在具有相同安全组的EC2实例上安装了Postgres,主服务器上的外部表表现正常。在同一RDS实例中的数据库之间的postgres_fdw起作用。
所有这些都让我认为这必须是我的Postgres RDS实例中的postgres_fdw对外连接存在问题。
host 'localhost'
在创建服务器命令选项中在相同的RDS实例之间查询数据库。如果你使用`host 'myinstance.xxxxxxx.amazonaws.com',你会像你描述的那样超时。编辑入站连接规则有所帮助是奇怪的,因为无论安全组规则如何,来自RDS的出站连接都是被禁止的。 - pail