Starting & Managing EC2 Servers

October 10th, 2006 by Jack
  1. Ensure that environment variables are correct, as per the previous post.
    If the command echo $JAVA_HOME outputs the path of a java binary, you should be all set.
  2. ec2-describe-images will 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.

  3. ec2-run-instances ami-aca84dc5 will 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
  4. ec2-authorize default -P tcp -p 22 -s [your ip address]/32 will update the firewall rules to allow you to SSH into the server from your IP address only. The “/32″ is the IP mask.
  5. 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.
  6. If you ever want to shut down an instance, use it’s instance id from the ec2-describe-instances command:
    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 |

2 Responses

  1. Adrian Holovaty Says:

    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.

  2. Jacks Says:

    Thanks for the corrections Adrian!

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.