Starting & Managing EC2 Servers
Jack - Ensure that environment variables are correct, as per the previous post.
If the commandecho $JAVA_HOMEoutputs the path of a java binary, you should be all set. ec2-describe-imageswill describe the various images on your S3 storage that are available:IMAGE ami-5bae4b32 ec2-public-images/getting-started.manifest 206029621532 available public IMAGE ami-68ae4b01 ec2-public-images/fedora-core4-base.manifest 206029621532 available public IMAGE ami-69ae4b00 ec2-public-images/fedora-core4-apache-mysql.manifest 206029621532 available public IMAGE ami-6dae4b04 ec2-public-images/fedora-core4-apache.manifest 206029621532 available public IMAGE ami-6fae4b06 ec2-public-images/fedora-core4-mysql.manifest 206029621532 available public IMAGE ami-aca84dc5 ubuntu-base/image.manifest 554263365884 available private
In this case, “ami-aca84dc5” is a custome image that we made.
ec2-run-instances ami-aca84dc5will create an instance of the “ami-aca84dc5” image.
It will take a few minutes to get started up. You can use ec2-describe-instances to check the status:RESERVATION r-58d53031 554263365884 default INSTANCE i-4bb45022 ami-aca84dc5 domU-12-31-33-00-01-6E.usma1.compute.amazonaws.com running RESERVATION r-5cd53035 554263365884 default INSTANCE i-4fb45026 ami-aca84dc5 pending
ec2-authorize default -P tcp -p 22 -s [your ip address]/32will update the firewall rules to allow you to SSH into the server from your IP address only. The “/32″ is the IP mask.- To open up ports for the general internet public, you’ll need to use:
ec2-authorize default -P tcp -p 80
In this case, we opened up TCP port 80 for a webserver. - If you ever want to shut down an instance, use it’s instance id from the
ec2-describe-instancescommand:
ec2-terminate-instances i-4bb45022
REMEMBER! When you terminate an instance, you will lose ALL of its data. Even if you start a new instance from your image, you will be starting from scratch!
Posted in ec2, walkthrough |
October 10th, 2006 at 4:43 pm
I’m new at this EC2 stuff, but I think there’s an error in this writeup. In step 2, I think you mean “ec2-describe-images” rather than “ec2-describe-instances”.
At any rate, thanks for this and the previous tutorial — they’ve been invaluable as I try to get EC2 working.
October 10th, 2006 at 4:47 pm
Thanks for the corrections Adrian!