Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a web site that runs on an Amazon EC2 Linux-based instance, and is mapped to a regular domain name (x.com). This site talks to a database on a second EC2 instance.

I need to shut down this instance and increase the computing power behind it... if I do that, how long will it take, and then when I spin the machine up again, will my site just come back online? Will the IP address, DNS info etc. all be preserved so the domain name will keep working, and it will still be able to talk to the DB?

FYI this is what I currently see for the web server in the AWS EC2 info panel (exact IP addresses changed slightly but you get the idea):

Public DNS: ec2-54-1-1-1.us-west-1.compute.amazonaws.com
Private DNS: ip-10-1-1-1.us-west-1.compute.internal
Private IPs: 10.1.1.1
share|improve this question
add comment

5 Answers

up vote 8 down vote accepted

Stopping and starting an EBS boot instance is very similar to simply rebooting the instance with a few exceptions, the most notable being:

  1. The instance is assigned a new internal IP address.

  2. The instance is assigned a new public IP address.

  3. Any Elastic IP address is disassociated with the instance.

  4. All data on ephemeral storage (often under /mnt) is lost

There are also some billing and availability implications which I described in this article:

Rebooting vs. Stop/Start of Amazon EC2 Instance
http://alestic.com/2011/09/ec2-reboot-stop-start

VPC instances have slightly different behavior including keeping Elastic IP addresses through stop/start.

If you are using an instance as a database server and you want to connect to it using the internal IP address (cheaper, faster) and you don't want to have to reconfigure the database clients after a stop/start, then you can assign an Elastic IP address to the instance and use the external Elastic IP DNS name. This will resolve to the current internal IP address after you re-associate the Elastic IP address to the restarted instance and your clients will pick up where they left off.

I go into more detail about this approach in this article:

Using Elastic IP to Identify Internal Instances on Amazon EC2
http://alestic.com/2009/06/ec2-elastic-ip-internal

As it sounds like you've anticipated, stop/start is an easy way to change the hardware powering your instance. I wrote about this along with some instructions and warnings in this article:

Moving an EC2 Instance to a Larger (or Smaller) Instance Type
http://alestic.com/2011/02/ec2-change-type

For your particular situation I would recommend assigning an Elastic IP address to the instance and changing your DNS to point to the Elastic IP address using a CNAME to the external DNS name. You could do this right after the stop/start, or you could do it ahead of time making sure everything works before the stop/start.

share|improve this answer
add comment

So, looks like you are not using Elastic IP, as I can see from your information.

I believe you must be using CNAME in the DNS to point to this instance. If you restart you Machine then this ec2-54-1-1-1.us-west-1.compute.amazonaws.com DNS name will change and your site will stop working.

As much internal IP is concerned, it will also change, unless you are using VPC, which you are not.

So, If I were you, I will be very careful in restarting this Machine.

As much as Time is concerned, it won't take anything more than couple of minutes.

Also, if you have any iptables running at the DB instance, which is allowing just this internal IP to connect to the DB, then it also won't work, as your internal IP will change.

So, Please be careful if you want to restart this instance, and think throughly about it.

share|improve this answer
add comment

Your internal IP/hostname will change and your Elastic IP will detach (Unless you're in a VPC).

Reattach the Elastic IP after you restart the instance. I regularly do this to change instance sizes and you're only looking at a couple minutes of downtime.

Verify Apache, and any other services are set to start (chkconfig if you running amazon linux ami).

share|improve this answer
add comment

As far as I can remember, stopping the system changing its type and starting it again should not take more than 5-10 mins (it goes unsaid that its a EBS backed system). For services to start once the system is back make sure you have all the services enabled to start on reboot (like for puppet on my ubuntu 12.04 I have it enabled in /etc/default/puppet). Make a note of the IP (I did it long back so dont remember clearly) and at most your IP can get detached from the system but it would still be there in your account so go in the Elastic IP section and associate it again with the restarted system and you will be fine.

share|improve this answer
add comment

As mentioned already, if you have an elastic IP, it will re-attach to the instance, so your DNS settings shouldn't need to be touched. One way or another, however, your private IP will change. This will likely mean you'll need to update your GRANT settings in mysql. 'Cos you've not just GRANT ALL PRIVILEGES ON *.* to 'somedude'@'%' ... right? ;)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.