个人工具

“UbuntuHelp:EC2StartersGuide”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(新页面: {{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 ...)
 
 
(未显示同一用户的2个中间版本)
第2行: 第2行:
 
{{Languages|UbuntuHelp:EC2StartersGuide}}
 
{{Languages|UbuntuHelp:EC2StartersGuide}}
 
=== Introduction ===
 
=== 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 [http://www.ubuntu.com/products/whatisubuntu/serveredition/features/ec2 official web page] for details on how to join the beta program.
+
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 [http://aws.amazon.com/ Amazon Web Services] requires you to go through the following steps that are described below:
 
Running Ubuntu Server Edition on [http://aws.amazon.com/ Amazon Web Services] requires you to go through the following steps that are described below:
 
<ol><li>Create your account on Amazon (if you do not already have one) and setup your keys
 
<ol><li>Create your account on Amazon (if you do not already have one) and setup your keys
第20行: 第20行:
 
</li><li>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.</li></ol>
 
</li><li>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.</li></ol>
  
=== Signing up for the beta ===
+
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.
<ol><li>Note your Amazon account number as described above
+
=== Getting the images ===
</li><li>Go to [http://www.ubuntu.com/products/whatisubuntu/serveredition/features/ec2 the beta sign up page] and follow the instructions there</li></ol>
+
The Official AMI Ids are the following:
 
+
{|border="1" cellspacing="0"
 +
|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                  || [http://uec-images.ubuntu.com/releases/10.04/release/ Release]
 +
|}
 +
Unofficial but well-maintained AMIs (8.04 Hardy through 9.04 Jaunty) are available from Eric Hammond's site [http://alestic.com/ Alestic.com].
 
=== Installing the API tools ===
 
=== Installing the API tools ===
<ol><li>Install the sun-java5-jre package.
+
The EC2 API tools is now available for 9.04 users to install and configure the software. For previous versions of Ubuntu please see [[UbuntuHelp:EC2APITools|here]].
</li><li>Go to the [http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&categoryID=88 Amazon EC2 resource Center] and download the Amazon EC2 Command-Line Tools.
+
<ol><li>Make sure you [[UbuntuHelp:Repositories/CommandLine#Adding_the_Universe_and_Multiverse_Repositories|have|multiverse enabled]] and run the following command:</li></ol>
</li><li>Unzip the ec2-api-tools.
+
</li><li>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:</li></ol>
+
  
<pre><nowiki>  
+
<pre><nowiki>
export EC2_HOME=$HOME/ec2-api-tools
+
sudo apt-get install ec2-api-tools
export PATH=$PATH:$EC2_HOME/bin
+
</nowiki></pre>
 +
<ol><li>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:</li></ol>
 +
 
 +
<pre><nowiki>
 
export EC2_PRIVATE_KEY=$HOME/<where your private key is>/pk-XXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem
 
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 EC2_CERT=$HOME/<where your certificate is>/cert-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.pem
export JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun/  
+
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/
 
</nowiki></pre>
 
</nowiki></pre>
 
<ol><li>Check to see if it's working by running the following command:</li></ol>
 
<ol><li>Check to see if it's working by running the following command:</li></ol>
第42行: 第60行:
 
ec2-describe-images -o self -o amazon
 
ec2-describe-images -o self -o amazon
 
</nowiki></pre>
 
</nowiki></pre>
 +
'''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.
 
<ol><li>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''':</li></ol>
 
<ol><li>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''':</li></ol>
  
第53行: 第72行:
 
</nowiki></pre>
 
</nowiki></pre>
 
=== Using the Ubuntu Images ===
 
=== Using the Ubuntu Images ===
Since the images and kernels are not public yet you will have to [http://www.ubuntu.com/products/whatisubuntu/serveredition/features/ec2 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:
+
The images and kernel are public, so they do not require any registration. To start using the AMI:
 
<ol><li>Start the images you want using one of the following commands:</li></ol>
 
<ol><li>Start the images you want using one of the following commands:</li></ol>
  
 
32 bits:
 
32 bits:
 
<pre><nowiki>
 
<pre><nowiki>
ec2-run-instances ami-977591fe  -k ec2-keypair
+
ec2-run-instances ami-xxxxx -k ec2-keypair
 
</nowiki></pre>
 
</nowiki></pre>
 
64 bits:
 
64 bits:
 
<pre><nowiki>
 
<pre><nowiki>
ec2-run-instances ami-8b7490e2  -k ec2-keypair -t c1.xlarge
+
ec2-run-instances ami-xxxxx -k ec2-keypair -t c1.xlarge
 
</nowiki></pre>
 
</nowiki></pre>
 +
where ami-xxxxx is the AMI ID found in the [[UbuntuHelp:EC2StartersGuide#Getting_the_images|above table]], and -t is the type of image:
 +
* [http://docs.amazonwebservices.com/AWSEC2/2009-03-01/DeveloperGuide/index.html?instance-types.html 2009-03-01 doc] [http://docs.amazonwebservices.com/AWSEC2/latest/DeveloperGuide/index.html?instance-types.html latest doc]
 +
* [http://aws.amazon.com/ec2/instance-types/ description of types] : [http://aws.amazon.com/ec2/#pricing pricing info]
 
<ol><li>To see the status of your instance, you can run the following command:</li></ol>
 
<ol><li>To see the status of your instance, you can run the following command:</li></ol>
  
第77行: 第99行:
  
 
<pre><nowiki>
 
<pre><nowiki>
ssh -i /path/to/keypair.pem root@<external-host-name>
+
ssh -i /path/to/ec2-keypair.pem ubuntu@<external-host-name>
 
</nowiki></pre>
 
</nowiki></pre>
 
Using the external host name that was listed as a result of the '''ec2-describe-instances''' command.
 
Using the external host name that was listed as a result of the '''ec2-describe-instances''' command.
=== First access to your instance ===
+
<ol><li>And, of course, you're being billed as long the host is running<<FootNote(The package [https://launchpad.net/screen-profiles 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.</li></ol>
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:
+
 
<pre><nowiki>
 
<pre><nowiki>
ssh -i /path/to/keypair.pem ubuntu@<external-host-name>
+
ec2-terminate-instances <instance_id>
 
</nowiki></pre>
 
</nowiki></pre>
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 ===
 
=== See Also ===
* The [http://www.ubuntu.com/products/whatisubuntu/serveredition/features/ec2 official web page] for Ubuntu on EC2
+
* The [http://www.ubuntu.com/cloud official web page] for Ubuntu Cloud
 
* The [[UbuntuHelp:EC2FAQ|EC2 Frequently Asked Questions]]
 
* The [[UbuntuHelp:EC2FAQ|EC2 Frequently Asked Questions]]
 
* The [http://aws.amazon.com/resources/ Amazon Web Services documentation]
 
* The [http://aws.amazon.com/resources/ Amazon Web Services documentation]
 +
=== Footnotes ===
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2010年5月19日 (三) 22:08的最新版本

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