【发布时间】:2017-08-31 15:57:18
【问题描述】:
我有一个 postgres 数据库,我可以使用以下方法转储并恢复到其他 postgres 安装,而不会出现问题:
pg_dump the_db_name > the_backup.sql
然后将备份复制到您的开发服务器,使用以下命令恢复:
psql the_new_dev_db < the_backup.sql
h/t to this link for that gem.
我还能够设置和配置 ec2、s3 和 eb(弹性 beanstalk)安装,以满足 wordpress、ruby 和 node js 的需求。但是,我正凝视着试图将 postgres 数据库导入亚马逊 rds 实例的深渊。我怀疑这不是 psql 问题,而是安全问题。任何关于尝试什么的建议,我将不胜感激。
我使用 .pem 文件连接到 aws。
我可以将 pgAdmin 配置为使用 ssh 隧道连接到我的 rds 实例。
我无法使用 psql nor can I configure pgAdmin to connect to my db in the way AWS recommends. 连接到我在 AWS 上的 postgres 数据库
在这两种情况下,我都会收到错误:
psql: could not connect to server: Connection timed out
Is the server running on host "xxxxxxx.us-west-2.rds.amazonaws.com" (xx.xx.xx.xx) and accepting
TCP/IP connections on port 5432?
在 rds 仪表板中,我看到我的实例属于两个安全组。当我点击一个时,它会说:
Your account does not support the EC2-Classic Platform in this region. DB Security Groups are only needed when the EC2-Classic Platform is supported. Instead, use VPC Security Groups to control access to your DB Instances. Go to the EC2 Console to view and manage your VPC Security Groups. For more information, see AWS Documentation on Supported Platforms and Using RDS in VPC
当我单击另一个安全组并转到其入站选项卡时,我看到有两个引用显示 Postgresql 正在端口 5432 上接收 TCP
此外,在 RDS 仪表板中,我看到我有一个 VPC ID,but after reading this article,我不确定要走哪条路,因为没有“支持的平台”字段。
如果我尝试从 pgAdmin 中的工作配置进行恢复,我会收到与连接类似的消息:
pg_restore: [archiver (db)] connection to database "ebdb" failed: could not connect to server: Connection timed out
Is the server running on host "XXXX.us-west-2.rds.amazonaws.com" (54.148.0.217) and accepting
TCP/IP connections on port 5432?
最后,我尝试在 pgAdmin 的 db 中调出 PSQL 控制台。它出现了,我可以运行 psql 命令,例如:
ebdb=> \conninfo
You are connected to database "ebdb" as user "awsuser" on host "127.0.0.1" at port "34883".
SSL connection (protocol: TLSv1.2, cipher: XXXX, bits: 256, compression: off)
但是,如果我尝试使用此命令在此处运行 pg_restore:
ebdb=> \! /usr/bin/pg_restore --dbname "ebdb" --section pre-data --section data --section post-data --create --clean --verbose "/home/awsuser/040517.backup"
它不会创建任何表格或推送任何数据。控制台点亮并闪烁所有 SQL 命令和数据,就好像它正常工作一样,但是当我回到 pgAdmin 并查看它时它仍然是空的。
【问题讨论】:
标签: postgresql amazon-web-services amazon-ec2 amazon-rds