简体   繁体   English

Heroku上的Rails应用程序无法连接到RDS

[英]Rails App on Heroku Can't Connect to RDS

I'm trying to get a Rails app that's hosted on Heroku, and currently using Heroku-Postges, to instead use an instance of AWS/RDS as its datastore. 我正在尝试获得一个托管在Heroku上且当前使用Heroku-Postges的Rails应用程序,以代替使用AWS / RDS实例作为其数据存储区。 The problem is that the rails app doesn't seem able get a connection and it just hangs every time it would talk to the DB. 问题在于,Rails应用程序似乎无法建立连接,并且每次与数据库通信时都会挂起。

I gather from reading a few articles about this that the way to point Heroku to it's DB is with a DATABASE_URL param in the form postgres://[dbuser]:[dbpass]@[subhost].amazonaws.com:5432/[dbname] . 我从阅读有关此问题的几篇文章中收集到,将Heroku指向数据库的方法是使用DATABASE_URL参数,其形式为postgres://[dbuser]:[dbpass]@[subhost].amazonaws.com:5432/[dbname]

Is that how it works? 那是怎么回事? I'm confused about how it overrides the database.yml values. 我对它如何覆盖database.yml值感到困惑。

I've also tried following instructions having to do with downloading a certificate and storing it in the config/ca folder and then appending ?sslca=config/ca/rds-ssl-ca-cert.pem&sslmode=require&encrypt=true . 我还尝试按照以下说明进行操作:下载证书并将其存储在config/ca文件夹中,然后附加?sslca=config/ca/rds-ssl-ca-cert.pem&sslmode=require&encrypt=true

I'm able to connect directly to the RDS instance using PGAdmin, so I know it's up, running and accessible. 我可以使用PGAdmin直接连接到RDS实例,因此我知道它已启动,正在运行且可访问。

Is there any other way I can get visibility into what's going on here? 还有什么其他方法可以让我了解这里的情况吗?

You don't need to fiddle with your database.yml values on Heroku. 您无需在Heroku上摆弄您的database.yml值。

But I assume you've already seen this tutorial on Heroku: Authorizing to RDS ; 但是我想您已经在Heroku上看到了本教程: 授权给RDS you'll need to set up the security groups for the RDS to accept incoming traffic from -all- IPs. 您需要为RDS设置安全组,以接受来自-all- IP的传入流量。

After opening it up to all IPs, you should also limit the RDS to accept only SSL as the article suggests. 将其开放给所有IP后,还应按照文章建议的那样将RDS限制为仅接受SSL。

More information for each RDS type (Mysql, Postgres eg) can be found at the AWS docs . 每种RDS类型(例如Mysql,Postgres)的更多信息可以在AWS文档中找到。

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

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