ITPub博客

首页 > 数据库 > PostgreSQL > postgres_fdw 无法通过域名 访问外部表问题

postgres_fdw 无法通过域名 访问外部表问题

原创 PostgreSQL 作者:babyyellow 时间:2022-02-23 10:33:55 0 删除 编辑



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/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
oracle MySQL Postgresql 专职数据库dba。 系统架构师。 mysql 官方认知dba 。 15年专职dba 经验。 潜意识沟通实证者 心理咨询师。 禅修布道者, 禅修指导员。 禅定实证者。

注册时间:2010-12-02

  • 博文量
    367
  • 访问量
    1908660