Mysql5.5 migration to RDS/Aurora - mysql

We have an mysql 5.5 installed and running on an AWS ec2 instance (r3.4xlarge type). We want to migrate to RDS/Aurora
1- RDS/Aurora can support mysql 5.6 and above. Should we first upgrade our database then move it to RDS/Aurora? Or can we do that using mysqldump directly?

Aurora has the ability to import from a 5.5 backup created with Percona XtraBackup. Dump the 5.5 database, put the backup in S3, and create aurora from that backup.
You may be able to set up replication from your ec2 instance to RDS MySQL or Aurora, as long as you're not using MyISAM tables.
Finally, you can use the AWS Database Migration tool to migrate from MySQL to Aurora.

There are two options, one is use database migration services to migrate the database from MySQL 5.5 to Aurora DB, it is recommended migration tool by Amazon, using this method you can be migrated without any outage.
Second is take backup and directly import in Aurora, it will be fast if both instances are in same region else move back up to s3 and restore it.

Related

Does AWS RDS support two way replication with local MySQL database?

I would like to sync the local MySQL database to Amazon RDS MySQL database. I found a solution for EC2 to RDS but not for Local Database to RDS.
I built a database including 12 tables which all I want to get backup them to cloud periodically or automatically.
I do not want to run EC2 server since I need only MySQL database to get backup on cloud.
I need a solution like Microsoft Database Sync Agent. Whenever changes detected in Local Database, it should be synced to the cloud database. How can I make this happen?
You could use the AWS Database Migration Service:
AWS Database Migration Service (AWS DMS) is a cloud service that makes it easy to migrate relational databases, data warehouses, NoSQL databases, and other types of data stores. You can use AWS DMS to migrate your data into the AWS Cloud, between on-premises instances (through an AWS Cloud setup), or between combinations of cloud and on-premises setups.
With AWS DMS, you can perform one-time migrations, and you can replicate ongoing changes to keep sources and targets in sync.
You can achieve this by following below steps.
Make a replica of local server to RDS.
Enable Query logging in local Database
Create a cron job which will process logging queries and it will execute queries on RDS instance in same order.
To generate a replica to RDS you can follow below steps.
You can't replicate your local database to RDS directly. Your need to dump you data and then after you can import it on RDS.
Instead of generating a dump file you can directly import data into RDS using below command.
mysqldump db_name | mysql -h 'other_hostname' db_name
You can find our more about this over here.
https://dev.mysql.com/doc/refman/5.7/en/copying-databases.html
Also first import tables & it's data then after import your triggers, routines & events. If you import together then there is a chances to get conflict and you job will be terminated.

migrating mysql instance on AWS RDS - mysql is not an option

I have an instance in RDS that is using mysql as the database engine. When I try to migrate that instance to a new one, it is only giving me options for Aurora and MariaDB. A few weeks ago I did the same thing to make a test version of the production database instance, and mysql was an option then. Any ideas on how I can make a copy of a mysql instance?

Is it possible to downgrade a AWS RDS from mysql 5.7 to lower version (say 5.6)

This is something i need to figure out, my company runs a number of prod RDS on AWS. Some of the mysql RDS run with 5.7 , i need to downgrade the mysql to 5.6 or 5.5 . Is this functionality provided by AWS.
Scenario: A mysql server already up and running with mysql version 5.7, Downgrade this to 5.6
-> If this is possible then what are the possible ways ?
-> How to do this ?
This is not something that AWS provides out of the box, however it can be solved with below 2 approaches depending on your database size and downtime that you can accept.
It might worth considering fixing application compatibility instead of downgrading DB which is more risky operation.
1. Dump, restore and switch method
Dump your currently running database with mysqldump utility. Start a new RDS instance with downgraded engine, load your dumped data into it. Switch your application to use RDS instance with downgraded engine.
2. Dump, restore, replicate & switch method
Dump your currently running database with mysqldump utility. Start a new RDS instance with downgraded MySQL engine, load your dumped data into it.
Set the new, downgraded DB instance as read replica of your old DB instance using mysql.rds_set_external_master and then start replication using mysql.rds_start_replication. Stop writes to your original DB, once the read replica catches up (you must monitor replication lag), run mysql.rds_reset_external_master which will promote your downgraded instance and turn off replication. Point your application to the downgraded RDS DB instance.
Method 2 will shorten your downtime to minimum, but is a bit more complex to execute. Here is a command reference to get familiar with to help you succeed: MySQL on Amazon RDS SQL Reference
You will find a great amount of examples in RDS documentation also - Importing and Exporting Data From a MySQL DB Instance:

Is it possible to migrate back from Amazon Aurora to native MySQL in Amazon RDS?

I saw Amazon introduced new Amazon Aurora MySQL migration from native MySQL to Amazon Aurora MySQL.
Would it be possible to migrate back from Amazon Aurora to regular MySQL with Amazon RDS?
Amazon's Aurora is MySQL wire compatible so you can always use tools such as mysqldump to get your data back out into a form that you could use to import back into a regular MySQL instance running in RDS, an EC2 instance or anywhere else for that matter.
Since posting this answer Amazon has also released the Database Migration Service which can be used to do zero downtime migrations between MySQL -> Aurora MySQL (Aurora also now supports PostgreSQL) and back. It also supports heterogeneous migrations such as from Oracle to Aurora MySQL or a number of other sources and targets.
If it's a small database, you can use tools such as Navicat or MySQL Workbench to export the data out. For big databases, you can download aws cli either for Windows or Linux, for Linux it comes with a pre-installed on Amazon Linux AMI. Use aws configure to set up credentials and regions. Use mysqldump from the cli remember the --single-transaction option to avoid locking and take dump preferable from slave replica.
For a subset of the data, you can either use: (Windows example)
mysql> SELECT * FROM database.table
WHERE ......
into OUTFILE '/location/of/path/dumpfile.txt'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY "\n";
Query OK....
to extract just what you need as flat files which is faster to load into any other MySQL env. You can also setup permission to load into s3 as flat files and export anywhere again if the file is not as big. But for huge data, please use mysqldump.
Percona has a series of steps to follow that outlines how to set up a MySQL replica from an Aurora master. You'd then be able to take it to RDS MySQL from there. In some cases this manual method might make sense.
Overview:
Snap the Aurora instance
Bring up a temp Aurora instance
Dump it (mysqldump)
Create the replica
Migrate traffic
However as #ydaetskcoR suggests, Amazon has the tool and the use case defined for setting up such a replica with DMS. I'd start here is a direct link to that use case.

Migrate PostgreSQL database to MySQL

Say that I want to migrate a PostgreSQL database on Heroku to MySQL on EC2 and I need to preserve the ID values in all the tables, what's the best way to accomplish that without using paid software?
It's quite simple.
I would have mySQL instance locally, heroku db:pull to get it from Heroku Postgres to your local development mySQL instance, back it up and then restore the backup to your EC2 MySQL instance