简体   繁体   English

AWS Elastic Beanstalk在部署的带有Django的EC2服务器上托管PostreSQL

[英]AWS Elastic Beanstalk hosting PostreSQL on deployed EC2 server with Django

I'm going through my first Elastic Beanstalk deployment. 我正在进行第一次Elastic Beanstalk部署。 I have my application loading as I'd like it to. 我按照我的意愿加载应用程序。 I now need to figure out how to auto deploy PostgreSQL with my deployment 我现在需要弄清楚如何使用我的部署自动部署PostgreSQL

I added the following to my requirements.txt psycopg2==2.5.1 我将以下内容添加到我的requirements.txt psycopg2==2.5.1

It appears to have installed 它似乎已安装

$ psql --version
$ psql (PostgreSQL) 9.2.5

settings.py in Django Django中的settings.py

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': 'database',
    'USER': 'user',
    'PASSWORD': 'password',
    'HOST': 'localhost',
    'PORT': '5432',
}
}

These settings work perfectly before deployment, here is the error I'm getting after deployment: 这些设置在部署之前完美运行,这是我在部署后得到的错误:

could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?

I don't think I have to open up firewall settings for an EC2 instance to read it's own database, do I? 我不认为我必须打开EC2实例的防火墙设置来读取它自己的数据库,是吗? Also because it's Django, everything should be auto created when the application runs. 另外因为它是Django,应用程序运行时应该自动创建所有内容。

As mentioned above, using PostgreSQL on the EC2 server was a bad idea for dynamic data and scaling. 如上所述,在EC2服务器上使用PostgreSQL对于动态数据和扩展来说是个坏主意。

Used RDS for this purpose and it worked flawlessly. 用于此目的的RDS使用完美无瑕。

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

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