I have an EBS backed EC2 running instance. The EBS store holds a database. I would like to create an AMI from this. Can someone please provide guidelines?
Thanks for your patience through a long question. I recognize there's similar information out there, but nothing really addresses what may go wrong.
This SO question:
http://stackoverflow.com/questions/4475532/creating-an-ec2-ami-with-an-ebs-backed-instance-is-it-possible
is specific to ElasticFox and I'm not using any tools (prefer command line). I don't believe the question is answered either.
This blog:
http://instantbadger.blogspot.com/2009/09/how-to-create-and-save-ami-image-from.html
while instructive about creating an AMI, does not mention EBS at all and I'm a little worried about all that data.
Thanks in advance!
Before going to your questions I would suggest that you back up your MySQL database to a file which is not stored as a snapshot or in an EBS before you start creating the image. (And of course test that you can restore it to somewhere else than your production system.)
I use:
mysqldump --add-drop-table -u root -p databasename > database.sql
to backup and:
mysql -u root -p databasename < database.sql
to restore.
A bit more info: I prefer to shut down the database when possible when snapshoting or creating images. That said I am not by any mean an MySQL expert, but here is some guidance from http://aws.amazon.com/articles/1663?_encoding=UTF8&jiveRedirect=1
Start a MySQL session on the instance, using the password you set above.
mysql -u root -p
In the mysql session, flush the tables to disk and acquire a lock. Flush the file system to disk and freeze it. Do not exit the MySQL session or you will lose the lock and snapshot potentially inconsistent database files!
FLUSH TABLES WITH READ LOCK;
SHOW MASTER STATUS;
SYSTEM sudo xfs_freeze -f /vol
Amazon console gives you an option to do this STUFF.
Just, login on to your aws console and navigate the instance-ID you wish to create an AMI.
That's it. This would have created an AMI. Please see: http://docs.amazonwebservices.com/AWSEC2/2011-05-15/UserGuide/index.html?Tutorial_CreateImage.html for a detailed information.
Make sure you always backup you MySQL by dumping as suggested by steenhulthin.
This link will help on creating your new EBS backed AMI: http://www.capsunlock.net/2009/12/create-ebs-boot-ami.html
I also suggest to place your MySQL data to a separate EBS volume or better RAIDed volumes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With