create extension postgres_fdw ;
create server pg_xxxxx foreign data wrapper postgres_fdw OPTIONS ( host 'pgm-xxxxxxxxxx.pg.rds.aliyuncs.com',port 'xxxx',dbname 'xxxxx_app') ;
create user MAPPING FOR postgres server pg_xxxxx OPTIONS ( user 'xxxx_app', password 'xxxxxxxxxxxx') ;
create foreign table pg__brand (
id bigint ,
name varchar ,
letter varchar ,
deleted integer ,
hidden integer
)
server pg_xxxxx
options ( schema_name 'xxxxx_app', table_name 'pg_brand') ;
10:23:01 > select * from pg__brand ;
ERROR: could not connect to server "pg_xxxxx"
描述: could not translate host name "pgm-wz9jxxxxxxxxxxxxxxxxxx.rds.aliyuncs.com" to address: Temporary failure in name resolution
pg 数据库的 外部表, 连接到 阿里云的 RDS postgresql 。
报这个错误, why
postgres_fdw 解析不了 阿里云的这个链接串。 虽然 设置了dns 解析。
也是用这个连接串建立的 forigon server 但是解析不了。
需要在 /etc/hosts 里面指定 ip 地址 跟 连接串。
nslookup pgm-wz9jxxxxxxxxxxxxxxxxxx.rds.aliyuncs.com
把解析出来的 ip 地址填到 /etc/hosts
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/133735/viewspace-2857366/ ,如需转载,请注明出处,否则将追究法律责任。