Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace an Amazon EC2 instance with a new one?

How to replace a Amazon EC2 instance with a new instance without removing tomcat7, mysql and other setting done on the instance?

like image 843
Gaurav Agarwal Avatar asked Jul 19 '12 13:07

Gaurav Agarwal


People also ask

How do I transfer an EC2 instance to another instance?

It's not possible to move an existing instance to another subnet, Availability Zone, or VPC. Instead, you can manually migrate the instance by creating a new Amazon Machine Image (AMI) from the source instance. Then, launch a new instance using the new AMI in the desired subnet, Availability Zone, or VPC.

Can I upgrade EC2 instance without losing data?

Alert Be careful when copying data from the old machine to the new one. It's better to keep the old data as a backup instead of overwriting it directly.

Can I upgrade EC2 instance?

You are free to upgrade or downgrade your on-demand EC2 instances as you please. If your instance is struggling to handle your workload, upgrading to a higher tier or another instance class can help your applications run smoother.


1 Answers

Simple:

  1. Stop the instance.
  2. Detach the volume(s) - if you just have one volume (the boot volume) detach that.
  3. Take a snapshot of the volume(s) for safekeeping (not strictly necessary in this case, but no-one ever got fired for taking backups of critical systems).
  4. Terminate the instance.
  5. Spin-up a new instance of the desired type (must be the same platform, i.e. x86 or x64, as the original).
  6. Wait until it's running, then stop it.
  7. Detach its' volume and delete it.
  8. Attach your original volumes to it (the boot volume must be /dev/sda1).
  9. Restart the new instance and re-assign Elastic IP if appropriate.
like image 137
Eight-Bit Guru Avatar answered Sep 20 '22 13:09

Eight-Bit Guru