How to create AMI from my EC2 instance with EBS support?

I have an EC2 instance with EC2 support. The EBS repository stores the database. I would like to create an AMI. Can anyone comment on the recommendations?

  • Should I disable MySQL?
  • Will my AMI try to connect to the same EBS store ?! (Disasters)
  • Will creating AMI automatically reduce my EBS volume and create a copy? (hoping this is one).

Thank you for your patience through a long question. I find out there similar information, but nothing really affects what could go wrong.

This SO question:

http://stackoverflow.com/questions/4475532/creating-an-ec2-ami-with-an-ebs- backed-instance-is-it-possible

specific to ElasticFox, and I do not use any tools (prefer the command line). I do not believe that this question is also answered.

This blog:

http://instantbadger.blogspot.com/2009/09/how-to-create-and-save-ami-image-from.html

although instructive about creating AMI, it doesn't mention EBS at all, and I'm a little worried about all this data.

Thanks in advance!

+6
source share
3 answers

Before moving on to my questions, I suggest you back up the MySQL database to a file that is not saved as a snapshot or in EBS before you start creating the image. (And of course, check that you can restore it to a location other than your production system.)

I use:

mysqldump --add-drop-table -u root -p databasename > database.sql 

for backup and:

 mysql -u root -p databasename < database.sql 

recovery.

  • No, you do not need to disable MySQL, but you need to prevent writing to the database when creating AMI.
  • Not. Creating AMI also creates a new snapshot of your EBS volume (with the contents as you did when creating the image).
  • yes see 2

A bit more information: I prefer to close the database when possible, when taking snapshots or creating images. However, I do not mean the MySQL expert, but here are some recommendations from http://aws.amazon.com/articles/1663?_encoding=UTF8&jiveRedirect=1

Start a MySQL session on the instance using the password above.

 mysql -u root -p 

In a mysql session, clear the tables on disk and acquire a lock. Reset the file system to disk and freeze it. Do not leave the MySQL session, otherwise you will lose blocking and snapshots of potentially inconsistent database files!

 FLUSH TABLES WITH READ LOCK; SHOW MASTER STATUS; SYSTEM sudo xfs_freeze -f /vol 
+1
source

The Amazon console gives you the ability to do this STUFF.

Just log in to your aws console and navigate to the id of the instance you want to create AMI.

  • Right-click the instance and click Stop.
  • Right-click on the instance and click Create AMI.
  • Enter a name for AMI and click OK.

What is it. This would create an AMI. See http://docs.amazonwebservices.com/AWSEC2/2011-05-15/UserGuide/index.html?Tutorial_CreateImage.html for details.

+3
source

Make sure you always back up MySQL using dumping, as suggested by steenhulthin.

This link will help you create a new AMI with EBS support: http://www.capsunlock.net/2009/12/create-ebs-boot-ami.html

I also suggest placing your MySQL data on a separate EBS volume or more accurate RAIDed volumes.

+1
source

Source: https://habr.com/ru/post/890326/


All Articles