个人工具

UbuntuHelp:EC2StartersGuide

来自Ubuntu中文

Wikibot讨论 | 贡献2008年12月16日 (二) 18:21的版本 (新页面: {{From|https://help.ubuntu.com/community/EC2StartersGuide}} {{Languages|UbuntuHelp:EC2StartersGuide}} === Introduction === This page is meant to give you the first keys to using Ubuntu's ...)

(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航, 搜索

Introduction

This page is meant to give you the first keys to using Ubuntu's official images on Amazon EC2. At this time these images are planned to be made available as Beta within the next few weeks. Please see the official web page for details on how to join the beta program. 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.

    Signing up for the beta

    1. Note your Amazon account number as described above
    2. Go to the beta sign up page and follow the instructions there

    Installing the API tools

    1. Install the sun-java5-jre package.
    2. Go to the Amazon EC2 resource Center and download the Amazon EC2 Command-Line Tools.
    3. Unzip the ec2-api-tools.
    4. 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_HOME=$HOME/ec2-api-tools
    export PATH=$PATH:$EC2_HOME/bin
    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-1.5.0-sun/ 
    
    1. Check to see if it's working by running the following command:
    ec2-describe-images -o self -o amazon
    
    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

    Since the images and kernels are not public yet you will have to register with our beta program first. Once you will have received our reply with the AMI references, you will be able to start and use your images as follow:

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

    32 bits:

    ec2-run-instances ami-977591fe  -k ec2-keypair
    

    64 bits:

    ec2-run-instances ami-8b7490e2  -k ec2-keypair -t c1.xlarge
    
    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/keypair.pem root@<external-host-name>
    

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

    First access to your instance

    The first time you connect to your instance you need to login as root as described in the above command. This will:

    • Unlock and generate a random password for the ubuntu user
    • Propose to install additional server tasks if needed
    • Log you out

    After writing down the password that has been generated for you, you can then immediately log back in using the following command:

    ssh -i /path/to/keypair.pem ubuntu@<external-host-name>
    

    and perform any administrative task you wish, using the sudo command to prefix any command that requires administrative privileges, together with the password that you just wrote down. It can be a good idea to change it with a password that you will remember easier using the passwd command.

    See Also