简体   繁体   中英

How Ruby on rails works with Amazon RDS

I have a ruby on rails run on amazon ec2, database is mySQL.

Now I want to use Amazon RDS to backup this database in case the ec2 fails.

I read through the Amazon RDS user guide,it tells how to create a DB instance.

My question is:

1.what is the relation between created DB instance and my ec2 database?

2.When the DB instance "connect" to my ec2, what will happen? The data used to send to ec2 mySQL server will be send to DB instance? Is the database totally shifted to DB instance?So before I connect I should creare a same database in DB instance and tell ec2 send data to RDS ever since

3.If not,how the DB instance know the ec2 is down and takeover the data?

EDIT: (Unsure)Is it that DB instance is just a place to put database.In order to use it,I need to set up database in DB instance,then connect to it by modifying database.yml file(this file tell rails server where the stored data goes).

How Is it possible to tell when the local database stops then at that time switch to DB instance?

There is absolutely no relationship between your EC2 MySQL DB and the RDS DB Instance. So what you are asking for is just not possible.

A better approach I would say is to have only RDS (No need to have MySQL running locally on EC2 instance). RDS takes snapshots regularly. Also, RDS is a managed service, so most of the MySQL administration tasks are handled by AWS and you don't have to worry. And you can rely on RDS snapshots from Backup perspective.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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