个人工具

UbuntuHelp:EC2StartersGuide

来自Ubuntu中文

跳转至: 导航, 搜索

Introduction

This page gives you the first keys to using Ubuntu's official images on Amazon EC2. Please follow the instructions below to use them. Running Ubuntu Server Edition on Amazon Web Services requires you to go through the following steps that are described below:

  1. Create your account on Amazon (if you do not already have one) and setup your keys
  2. Install Amazon EC2 API Tools
  3. Instantiate your images(s)
  4. Configure your instance

<<Anchor(amazon_account_setup)>>

Setting up an Amazon account

  1. Go to http://aws.amazon.com, and select Sign-up Now. Sign in to your existing Amazon account or create a new one.
  2. Go to http://aws.amazon.com/ec2, and select "Sign Up for Amazon EC2".
    1. Enter your credit card information.
    2. Complete your signup for the Amazon EC2 service.
  3. On the thank you page, select "Create a New X.509 Certificate". Note that if you already have an X.509 certificate you are only able to download the certificate itself, not the private key. If you no longer have the private key you will need to generate a new X.509 certificate.
    1. Select "Yes" to create a new certificate.
    2. Download your Private Key and Certificate file.
    3. Note your AWS account ID # by going to http://aws.amazon.com/ec2 by moving the mouse over "Your Web Services Account" and select "Your Account Activity". Your account number will be at the top of this page in XXXX-XXXX-XXXX format.

    If at a later time you discover you need to generate a new X.509 certificate, click on "Your Account" at the top of the EC2 console page. You may need to click the small button with two down arrows near the top right of the EC2 console page to make the "Your Account" link visible. Then in the "Access Credentials" box, click the tab named "X.509 Certificates" and click "Create a New Certificate". Download the private key and certificate when prompted.

    Getting the images

    The Official AMI Ids are the following:

    Release Region i386 x86_64
    9.10>Karmic Koala us-east-1 ami-bb709dd2 ami-55739e3c
    us-west-1 ami-c32e7f86 ami-cb2e7f8e
    eu-west-1 ami-2fc2e95b ami-05c2e971
    8.04>Hardy Heron us-east-1 ami-59b35f30 ami-27b35f4e
    us-west-1 ami-3954057c ami-c954058c
    eu-west-1 ami-a1d9f2d5 ami-add9f2d9
    Lucid Lynx Release

    Unofficial but well-maintained AMIs (8.04 Hardy through 9.04 Jaunty) are available from Eric Hammond's site Alestic.com.

    Installing the API tools

    The EC2 API tools is now available for 9.04 users to install and configure the software. For previous versions of Ubuntu please see here.

    1. Make sure you have|multiverse enabled and run the following command:
    sudo apt-get install ec2-api-tools
     
    1. Make sure you have the following environment variables set up in your shell profile. This is accomplished by adding the following lines to your ~/.bashrc if you use bash as your shell:
    export EC2_PRIVATE_KEY=$HOME/<where your private key is>/pk-XXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem
    export EC2_CERT=$HOME/<where your certificate is>/cert-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem
    export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/
    
    1. Check to see if it's working by running the following command:
    ec2-describe-images -o self -o amazon
    

    Note: If this fails due to "`Client.AuthFailure`" then ensure you have signed up for both AWS and ec2 with amazon.com, and have provided valid payment details. Also double check that the `EC2_PRIVATE_KEY` and `EC2_CERT` point to the correct locations.

    1. To use public AMIs you have to generate an ssh key. Run the following command which will also save the private key returned to a local file called ec2-keypair:
    ec2-add-keypair ec2-keypair > ec2-keypair.pem
    
    1. Make sure the permissions on the file is 600
    chmod 600 ec2-keypair.pem
    

    Using the Ubuntu Images

    The images and kernel are public, so they do not require any registration. To start using the AMI:

    1. Start the images you want using one of the following commands:

    32 bits:

    ec2-run-instances ami-xxxxx -k ec2-keypair
    

    64 bits:

    ec2-run-instances ami-xxxxx -k ec2-keypair -t c1.xlarge
    

    where ami-xxxxx is the AMI ID found in the above table, and -t is the type of image:

    1. To see the status of your instance, you can run the following command:
    ec2-describe-instances
    
    1. Authorize network access to the ssh port by running the following commands:
    ec2-authorize default -p 22
    
    1. To login to your instance you have to run the following command:
    ssh -i /path/to/ec2-keypair.pem ubuntu@<external-host-name>
    

    Using the external host name that was listed as a result of the ec2-describe-instances command.

    1. And, of course, you're being billed as long the host is running<<FootNote(The package screen-profiles has an extension that allows to display a cost estimate on your host terminal session)>>, so you will probably want to shut it down when you're done.
    ec2-terminate-instances <instance_id>
    

    See Also

    Footnotes