Kiki Zhao的英语学习天地

努力学习英语!!!
Amazon EC2之初体验(一)

Amazon EC2之初体验

由于项目的需要,这几个月都在使用AmazonEC2。这个东西对于国内的用户来说比较陌生,但是听国外的同事说,这个在美国可是相当流行。这里简单介绍一下,大家有兴趣也可以试试。

EC2全称Amazon Elastic Compute Cloud,是Amazon2006年推出的新一代hosting服务,目前尚处于beta阶段,但是使用中没有发现什么问题,相当稳定。

EC2的功能介绍:http://www.amazon.com/gp/browse.html?node=201590011

要用EC2,有两个概念必须先了解。

Amazon Machine Image (AMI) - An Amazon Machine Image (AMI) is an encrypted file stored in Amazon S3. It contains all the information necessary to boot instances of your software.

Instance - The running system based on an AMI is referred to as an instance. All instances based on the same AMI begin executing identically. Any information on them is lost when the instances are terminated or if they fail.

EC2有个大概了解之后,就可以开始在网上申请使用此项服务了。

1.         首先必须先在Amazon Web Services上注册一个用户http://www.amazon.com/gp/browse.html?node=3435361

2.         注册完毕后,回到Amazon Web Services页面,点击左边Browse Web Services中的Amazon Elastic Compute Cloud (Beta),然后在EC2页面中,点击右边的Sign Up For This Web Service。这时系统会显示一个收费列表(如下)及要求你输入你的支付方式。

Instances

$0.10 per instance-hour consumed (or part of an hour consumed)

Data Transfer

$0.10 per GB - all data transfer in

$0.18 per GB - first 10 TB / month data transfer out

$0.16 per GB - next 40 TB / month data transfer out

$0.13 per GB - data transfer out / month over 50 TB

可以看到EC2完全按你的需要收费。如果需要多个实例,就可以多开几个,不需要了就关了,没有传统hosting的固定合同。

里面还提到Amazon的另一个服务Amazon Simple Storage Service ,简称Amazon S3,主要用于存贮数据。EC2是不负责储存的,每次instance关掉重启除/mnt外所有数据还原成VM镜像的初始状态,/mnt则被清空。储存由S3 (Amazon Simple Storage Service)服务负责。可以看看我的帐单。

Instance基本硬件配置:Xen VM2G CPU 1.7G RAM, 文件系统Ext3: 10G /(镜像持久), 140G /mnt(每次重启被清空)。

OS主要为LinuxWindows,可以从http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=101挑选自己需要的已经有的AMI

 

用户注册后,准备使用它了,这里有几项前提条件。

l         下载并安装最新的Java Runtime Environment from http://java.sun.com/javase/downloads/index_jdk5.jsp

l         下载Amazon EC2 command-line tools from: http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351&categoryID=88

"Resource Center"->”Amazon Elastic Compute Cloud (Beta) “->"Developer Tools".

l         下载PuTTY & PuTTYgen from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

 

设置工具

1.      C盘下创建一个文件夹来存储和EC2相关的东西,如c:\EC2(当然不一定要在C盘)

2.      创建并下载private key文件和X.509 certificate

"Your Web Services Account"->" AWS Access Identifiers"

-> X.509 Certificate 里的"Create New", 保存他们到c:\EC2,命名为"privatekey.pem" and "509certificate.pem"

3.      c:\EC2下创建一个bat文件

@echo off

set EC2_HOME=c:\EC2

set PATH=%PATH%;%EC2_HOME%\bin

set EC2_PRIVATE_KEY=c:\ec2\PrivateKey.pem

set EC2_CERT=c:\ec2\509certificate.pem

set JAVA_HOME=C:\Program Files\Java\jre1.6.0_02

"%JAVA_HOME%\bin\java" -version

4.      解压缩Amazon EC2 command-line tools工具并且将/lib/bin文件夹移至c:\EC2下。这样在EC2目录下就有两个文件夹,一个bat文件和2个认证文件。

5.      在运行中输入CMD,切换至c:\EC2,然后运行

C:\EC2>ec2

java version "1.6.0_02"

Java(TM) SE Runtime Environment (build 1.6.0_02-b06)

Java HotSpot(TM) Client VM (build 1.6.0_02-b06, mixed mode, sharing) 

posted on 2007-08-21 17:33  Kiki  阅读(3856)  评论(1编辑  收藏  举报