I tried to deploy my Django application to AWS beanstalk. For this I was following this tutorial: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html
我尝试将我的Django应用程序部署到AWS beanstalk。为此我遵循了这个教程:http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html
However, when I use deploy the app using eb create
, I get a MySQL error
但是,当我使用eb create部署应用程序时,我收到MySQL错误
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock
I am guessing this is because I haven't done any database configuration (the document above doesn't mention a configuration step even once). So, I tried to add an RDS database using this guide: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.db.html.
我猜这是因为我没有做任何数据库配置(上面的文档甚至没有提到配置步骤一次)。因此,我尝试使用本指南添加RDS数据库:http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.db.html。
Now, I am getting the error that
现在,我收到了错误
RDS requires that you have a subnet selected in at least two Availability Zones.
When I tried to create this subnets, other issues involving VPN's etc crop up. Can someone please help me get a simple django app up and running on the aws? Thanks!
当我尝试创建这个子网时,涉及VPN等的其他问题就会出现。有人可以请帮助我在aws上运行一个简单的django应用程序吗?谢谢!
4 个解决方案
#1
1
Since you are using elastic beanstalk,do not create separate RDS. You can use the AWS Console to deploy the django application. Choose the RDS configuration while deploying the application and the subnet settings are all taken care by it self
由于您使用的是弹性beanstalk,因此请勿创建单独的RDS。您可以使用AWS控制台部署django应用程序。在部署应用程序时选择RDS配置,子网设置都由它自己处理
#2
0
I assume you have HOST = 'localhost' in your settings.py. Django will try to connect via Unix socket to Mysql. You probably want to connect to MySQL via TCP.
我假设你的settings.py中有HOST ='localhost'。 Django将尝试通过Unix套接字连接到Mysql。您可能希望通过TCP连接到MySQL。
Inside the DATABASES dict in settings.py: Set the HOST to 127.0.0.1
在settings.py中的DATABASES dict内:将HOST设置为127.0.0.1
#3
0
You need to create subnet as described here,
您需要按此处所述创建子网,
Create a DB subnet group
创建数据库子网组
Open the Amazon RDS console at https://console.aws.amazon.com/rds/.
通过以下网址打开Amazon RDS控制台:https://console.aws.amazon.com/rds/。
In the navigation pane, click Subnet Groups.
在导航窗格中,单击“子网组”。
Click Create DB Subnet Group.
单击“创建数据库子网组”。
Click Name, and then type the name of your DB Subnet Group.
单击“名称”,然后键入数据库子网组的名称。
Click Description, and then describe your DB Subnet Group.
单击“描述”,然后描述您的数据库子网组。
Next to VPC ID, select the ID of the VPC that you created.
在VPC ID旁边,选择您创建的VPC的ID。
Click the add all the subnets link in the Add Subnet(s) to this Subnet Group section.
单击“添加子网”中的“添加所有子网”链接到此“子网组”部分。
When you are finished, click Yes, Create In the confirmation window, click Close.
完成后,单击“是,创建”在确认窗口中,单击“关闭”。
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo-vpc-rds.html#AWSHowTo-vpc-rds-subnet
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo-vpc-rds.html#AWSHowTo-vpc-rds-subnet
#4
0
Create the database as you create the app.
在创建应用程序时创建数据库。
eb create --database --database.engine mysql --region eu-west-1
Update:
更新:
You can set database user and password like this:
您可以像这样设置数据库用户和密码:
eb create --database --database.engine mysql --database.password <password> --database.username <username> --region eu-west-1
Here are all available options. http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-create.html
以下是所有可用选项。 http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-create.html
#1
1
Since you are using elastic beanstalk,do not create separate RDS. You can use the AWS Console to deploy the django application. Choose the RDS configuration while deploying the application and the subnet settings are all taken care by it self
由于您使用的是弹性beanstalk,因此请勿创建单独的RDS。您可以使用AWS控制台部署django应用程序。在部署应用程序时选择RDS配置,子网设置都由它自己处理
#2
0
I assume you have HOST = 'localhost' in your settings.py. Django will try to connect via Unix socket to Mysql. You probably want to connect to MySQL via TCP.
我假设你的settings.py中有HOST ='localhost'。 Django将尝试通过Unix套接字连接到Mysql。您可能希望通过TCP连接到MySQL。
Inside the DATABASES dict in settings.py: Set the HOST to 127.0.0.1
在settings.py中的DATABASES dict内:将HOST设置为127.0.0.1
#3
0
You need to create subnet as described here,
您需要按此处所述创建子网,
Create a DB subnet group
创建数据库子网组
Open the Amazon RDS console at https://console.aws.amazon.com/rds/.
通过以下网址打开Amazon RDS控制台:https://console.aws.amazon.com/rds/。
In the navigation pane, click Subnet Groups.
在导航窗格中,单击“子网组”。
Click Create DB Subnet Group.
单击“创建数据库子网组”。
Click Name, and then type the name of your DB Subnet Group.
单击“名称”,然后键入数据库子网组的名称。
Click Description, and then describe your DB Subnet Group.
单击“描述”,然后描述您的数据库子网组。
Next to VPC ID, select the ID of the VPC that you created.
在VPC ID旁边,选择您创建的VPC的ID。
Click the add all the subnets link in the Add Subnet(s) to this Subnet Group section.
单击“添加子网”中的“添加所有子网”链接到此“子网组”部分。
When you are finished, click Yes, Create In the confirmation window, click Close.
完成后,单击“是,创建”在确认窗口中,单击“关闭”。
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo-vpc-rds.html#AWSHowTo-vpc-rds-subnet
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo-vpc-rds.html#AWSHowTo-vpc-rds-subnet
#4
0
Create the database as you create the app.
在创建应用程序时创建数据库。
eb create --database --database.engine mysql --region eu-west-1
Update:
更新:
You can set database user and password like this:
您可以像这样设置数据库用户和密码:
eb create --database --database.engine mysql --database.password <password> --database.username <username> --region eu-west-1
Here are all available options. http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-create.html
以下是所有可用选项。 http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-create.html