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.

Lets say I have an application server and a database server on Amazon EC2. If the db server fails and restarts, how can the app server know the new internal ip of the db server and automatically continue working with it?

share|improve this question

2 Answers 2

up vote 0 down vote accepted

A reboot will keep it's settings. If you bring up a new instance then you'll need some way to manage the IP's. A startup script is probably the way to go. Pull the instance metadata and update a config file (perhaps in S3) or DNS entry. You can also use an elastic IP and configure a cname which will resolve to the internal address within the EC2 environment. To do this, assign an elastic IP and note the public DNS string (there's a pattern but it's good to check) and create the cname record with it. The advantage with elastic IP cnames is you don't have to wait for DNS propagation.

share|improve this answer
    
Any idea where I can find example of such startup script? –  Niro Jan 6 '10 at 15:47

You could have the DB server tell the application server where it is by writing a simple externally facing update URL on your application server. You can get the internal IP from the boot metadata from the DB server. Maybe a simple shell script like this in rc.local on the DB server (assuming you are using a linux instance):

LOCALIP=`curl http://169.254.169.254/latest/meta-data/local-ipv4`
curl http://<yourexternalappname.com>/updatedbip?ip=$LOCALIP&somesharedsecret=<password>
share|improve this answer

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.