关于EC2的AKI和ARI(英文)

Amazon has released an updated version of the Elastic Compute Cloud (EC2) API with the version name 2008-02-01. This release includes a number of new features that were not available in the 2007-08-29 version of the API that I discussed in the book Programming Amazon Web Services (PAWS). To help keep my readers up-to-date with the capabilities of the EC2 service, this article contains a description of the new features and demonstrates how to use them in code.

The 2008-02-01 EC2 API provides three important new features:

User Selectable Kernels – Choose to run an alternative Linux kernel on your instance, in order to benefit from newer or differently-configured kernel versions. Availability Zones – Choose the locations in which your instances will run. You can distribute your instances across different locations for better fault tolerance, or concentrate them in a single location to minimize network latency and data transfer costs. Elastic IP Addresses – Reserve your own public IP addresses in the EC2 environment, and assign these addresses to your instances on demand. Elastic IPs allow you to make an instance accessible at a known public IP address, without the need to use a dynamic DNS service to simulate a static IP.Getting Started

The code examples in this article are based on an updated EC2 client implementation that has been added to the sample code archive on the PAWS Examples web site. In this article I will use the Ruby implementation, but the archive also includes equivalent implementations in Java and Python.

Download the latest PAWS_examples.zip archive file, unzip it, and change to thePAWS_examples/ruby directory. This directory should contain two EC2 clients:

$ cd PAWS_examples/ruby$ ls EC2*EC2.rb EC2_2008-02-01.rb

The first file, EC2.rb, contains the original EC2 API implementation from the PAWS book. The second file, EC2_2008-02-01.rb, contains new and updated methods that work with the latest EC2 API version 2008-02-01. This is the EC2 client we will use in this article.

Start an interactive Ruby session with the irb command, and create a client object from the latest EC2 API implementation:

irb> require 'EC2_2008-02-01' # => trueirb> ec2 = EC2.new('YourAwsAccessKey', 'YourAwsSecretKey')

To confirm that you are using the correct API version, use thedescribe_images method to list the Amazon Machine Images (AMIs) provided to the public by Amazon. The listing should include different image types identified by the :type attribute. The image types should include machine,kernel and ramdisk images. Some machine images will also have :kernel_idand :ramdisk_id attributes.

Here is a portion of the results from a listing of Amazon’s images. The first item is a kernel image, and the second is a machine image that includes kernel and ramdisk identifier attributes:

irb> require 'pp' # => trueirb> pp ec2.describe_images(:owners => 'amazon')[{:type=>"kernel", :is_public=>true, :architecture=>"x86_64", :owner_id=>"amazon", :state=>"available", :location=> "ec2-public-images/vmlinuz-2.6.18-xenU-ec2-v1.0.x86_64.aki.manifest.xml", :id=>"aki-9800e5f1"}, . . . {:type=>"machine", :is_public=>true, :architecture=>"i386", :kernel_id=>"aki-a71cf9ce", :owner_id=>"amazon", :ramdisk_id=>"ari-a51cf9cc", :state=>"available", :location=>"ec2-public-images/fedora-8-i386-base-v1.06.manifest.xml", :id=>"ami-f51aff9c"},

The kernel and ramdisk image types are new additions to the EC2 API. They make it possible to select an alternative Linux kernel.

User Selectable Kernels

The User Selectable Kernels feature allows you to choose to run an alternative Linux kernel on your instances, in place of the default kernel provided by Amazon. In prior versions of the EC2 API there was only one kernel available for each instance type; a variation of the Linux 2.6.16 Xen kernel. You can now choose from a collection of kernels that have been made available by Amazon or Amazon-endorsed vendors.

With a range of kernels now available in EC2, it is easier to take advantage of kernel improvements or alternative kernel configuration settings that may benefit your application. Unfortunately, the range of kernels is still limited to what Amazon and other vendors provide. You cannot create your own customized kernel, though hopefully it will become possible to do so in the future.

New Image Types: AKIs and ARIs join AMIs

Alternative kernels are made available in the EC2 environment as a new type of image, known as an Amazon Kernel Image (AKI). Because some kernels require additional drivers when they launch, there is another new image type called an Amazon RAM disk Image (ARI) which stores driver files. These two image types join the venerable Amazon Machine Image (AMI) which has always been used in EC2 to store an instance’s root volume.

On the Amazon Machine Images page, you can see a listing of the publicly available kernel, ramdisk, and machine images. This listing contains links to pages with further information about the images. For example, the page for a kernel image may describe the kernel’s configuration, indicate whether it requires a ramdisk image, and include links to module files that are compatible with the kernel. This information can help you decide which kernel will work best with your application.

You can also use the DescribeImages API operation to programmatically list all the images that are available to you. The listing returned by the service will include an attribute that describes the type of each image, and you can also tell the type of an image from the beginning of its identifier string which will be ami-, aki- or ari-.

Amazon machine images may be configured with default values for the kernel and ramdisk that instances will use. If you list the attributes for Amazon’s Fedora 8 public AMI (ami-f51aff9c), you can see that it is associated with the kernel image aki-a71cf9ce and ramdisk image ari-a51cf9cc:

irb> pp ec2.describe_images(:image_ids => 'ami-f51aff9c')[{:type=>"machine", :location=>"ec2-public-images/fedora-8-i386-base-v1.06.manifest.xml", :is_public=>true, :owner_id=>"amazon", :architecture=>"i386", :kernel_id=>"aki-a71cf9ce", :state=>"available", :ramdisk_id=>"ari-a51cf9cc", :id=>"ami-f51aff9c"}]Selecting Your Kernel

To run your instance with an alternative kernel, you specify the identifiers of your chosen kernel and ramdisk images when you perform the RunInstances operation. Not all kernels require extra drivers, so you will only need to include the ramdisk identifier when the kernel’s description page indicates that the ramdisk is necessary.

You can select any of the available kernel images when you launch an instance, however it is your responsibility to check that the kernel will actually work with the AMI you are launching. EC2 will not prevent you from using a kernel that is incompatible with the machine’s image or the instance’s architecture, nor will it force you to use the correct ramdisk image. Before you launch an instance with a non-standard kernel, you should always double-check that it is compatible with your AMI.

To demonstrate how to select an alternative kernel, we will launch an instance based on the Fedora 4 Getting Started machine image (ami-2bb65342) that has been available for some time. However, we will launch it with the new 2.6.18 Xen 3.1.0 kernel (aki-9b00e5f2) instead of the default 2.6.16 version.

To launch the instance, invoke the run_instances method and provide a:kernel_id option to specify the alternative kernel’s identifier. Because this newer kernel does not require a ramdisk image, you will not need to include the:ramdisk_id option.

irb> reservation = ec2.run_instances('ami-2bb65342', 1, 1, {:key_name => 'ec2-private-key', :kernel_id => 'aki-9b00e5f2'})

Once the instance has entered the running state and has been assigned a public DNS name…

irb> pp ec2.describe_instances. . . :instances=> [{:public_dns=>"ec2-72-44-52-218.compute-1.amazonaws.com", :image_id=>"ami-2bb65342", :kernel_id=>"aki-9b00e5f2", :state=>"running", :id=>"i-fb1ad992", . . .

…log in to the instance using ssh, and confirm that it is indeed running with the 2.6.18 Linux kernel.

$ ssh -i ec2-private-key.pem root@ec2-72-44-52-218.compute-1.amazonaws.comec2# uname --kernel-release2.6.18-xenU-ec2-v1.0

On an instance, you can find out which kernel and ramdisk images it is using by referring to the kernel-id and ramdisk-id metadata items:

ec2# curl -f http://169.254.169.254/2008-02-01/meta-data/kernel-idaki-9b00e5f2

If your instance is running with a non-standard kernel and ramdisk, these metadata items will return the identifier values. If you did not specify an alternative kernel or ramdisk, or if the instance was launched using an earlier API version, these metadata items may return 404 errors. This is the case for the instance we just launched, which does not have an associated ramdisk image:

ec2# curl -f http://169.254.169.254/2008-02-01/meta-data/ramdisk-idcurl: (22) The requested URL returned error: 404Modules for User Selected Kernels

If you launch an instance with a non-standard kernel, it is likely that the machine image will not include compatible kernel modules. If you check the module files available by default on the Getting Started AMI, you will see that they are not compatible with the new kernel you are running:

ec2# ls /lib/modules2.6.16-1.2069_FC4 2.6.16-xenU 2.6.17-1.2142_FC4

To obtain kernel modules that are compatible with your chosen kernel, you must either obtain pre-compiled module files, or compile them yourself. Fortunately, the information page for the 2.6.18 kernel includes a download link for compatible modules. To install these modules, you can simply download an archive file and extract its contents to the root of your instance’s file system:

ec2# wget http://ec2-downloads.s3.amazonaws.com/ec2-modules-2.6.18-xenU-ec2-v1.0-i686.tgzec2# tar xzf ec2-modules-2.6.18-xenU-ec2-v1.0-i686.tgz -C /ec2# ls /lib/modules2.6.16-1.2069_FC4 2.6.16-xenU 2.6.17-1.2142_FC4 2.6.18-xenU-ec2-v1.0ec2# modprobe -l/lib/modules/2.6.18-xenU-ec2-v1.0/kernel/security/seclvl.ko/lib/modules/2.6.18-xenU-ec2-v1.0/kernel/security/commoncap.ko. . .

Pre-prepared module files are only available for some of the alternative kernels. For the kernels without readily available modules, you should check the EC2 developer forums to see if anyone has posted details on where to find modules, or how to compile them.

Bundling AMIs to Use a Specific Kernel

When you use the latest version of the ec2-bundle-vol tool to create your own AMI from a running instance, the tool will refer to the instance’s metadata to discover which kernel and ramdisk images it is using. The tool will then automatically apply these settings to the bundled image it creates, which means that you can easily bundle a new AMI from an instance without having to manually specify the kernel or ramdisk identifiers.

If you wish to explicitly set the kernel and ramdisk identifiers, the ec2-bundle-voland ec2-bundle-image tools allow you to do so by providing the --kernel and --ramdisk options. There are a few situations where you may need to explicitly set these options:

If you are bundling an image created outside EC2, and you want the AMI to use an alternative kernel or ramdisk. If you are bundling a running instance, but you want the resultant AMI to use a different kernel or ramdisk. If you do not trust the ec2-bundle-vol tool to retrieve the instance’s settings from the metadata service.Availability Zones

The Availability Zones feature allows you to specify the location, or locations, where your instances will be deployed and run by the EC2 environment. By controlling the placement of your instances, you can easily disperse them across multiple EC2 locations for better fault tolerance, or concentrate them in a single location to minimize network latency and data transfer fees.

You can specify the location for your instances when you launch them, or you can skip this step and allow EC2 to decide where to place your instances based on the availability and health of each location. In prior API versions, EC2 always chose the location for instances and there was no way you could control, or query, their location.

EC2 Locations: Regions and Zones

EC2 data center locations are described in terms of “regions” and “availability zones”. A region is a broad expanse such as a country or geographic area. At present there is only one EC2 region available, the U.S. E

时间: 2024-09-20 14:38:56

关于EC2的AKI和ARI(英文)的相关文章

Creating a new EC2 AMI from within VMware (英文)

Creating a new EC2 AMI from within VMware or from VMDK files I've used VMware for many years to allow me to test and develop various server configurations and distributions. It's where I played with Linux-VServer, User Mode Linux (UML), Kernel Based

关于EC2上的ami的kernel

EC2上,我使用的rightscale的AMI为centos5的V1版本,该版本的kernel版本为2.6.16. 可以使用下面的方法升级到2.6.18. 因为,amazon允许在启动的时候选择kernel版本,amazon提供的最新内核的版本为2.6.18(其实,rightscale就是使用amazon提供的2.6.18的内核),所以,可以选择使用2.6.18的kernel启动以后再将INSTANCE重新打包成AMI.下面有官方文档. 注:使用了2.6.18kernel后,启动后,查看outp

OpenStack详细解读:定义,好处与使用实例

OpenStack是一个旨在为公共及私有云的建设与管理提供软件的开源项目.它的社区拥有超过130家企业及1350位开发者,这些机构与个人都将OpenStack作为基础设施即服务(简称IaaS)资源的通用前端.OpenStack项目的首要任务是简化云的部署过程并为其带来良好的可扩展性.本文希望通过提供必要的指导信息,帮助大家利用OpenStack前端来设置及管理自己的公共云或私有云. 内容详解 OpenStack包括数个由社区维护的项目,具体情况我将在后文中详加阐述. ● OpenStack Co

什么是OpenStack 开源的云计算管理平台项目_OpenStack

OpenStack是一个由NASA(美国国家航空航天局)和Rackspace合作研发并发起的,以Apache许可证授权的自由软件和开放源代码项目. OpenStack是一个开源的云计算管理平台项目,由几个主要的组件组合起来完成具体工作.OpenStack支持几乎所有类型的云环境,项目目标是提供实施简单.可大规模扩展.丰富.标准统一的云计算管理平台.OpenStack通过各种互补的服务提供了基础设施即服务(IaaS)的解决方案,每个服务提供API以进行集成. OpenStack是一个旨在为公共及私

介绍0penstack存储入门的一些必要理论知识

OpenStack 其实有三个与存储相关的组件,这三个组件被人熟知的程度和组件本身出现时间的早晚是相符的,按熟悉程度排列如下: Swift-提供对象存储(Object Storage),在概念上类似于 Amazon S3 服务, 不过 swift 具有很强的扩展性.冗余和持久性,也兼容 S3 API.对象存储支持多种应用,比如复制和存档数据.图像或视频服务,存储次级静态数据,开发数据存储整合的新应用,存储容量难以 估计的数据,为 Web 应用创建基于云的弹性存储. Glance-提供虚机镜像(I

openstack之Glance

一.Glance简介.基本概念: Glance是openstack项目中负责镜像管理的模块,其功能包括虚拟机镜像的查找.注册和检索等操作. Glance提供restful API可以查询虚拟机镜像的metadata,并且可以获取镜像. 通过Glance,虚拟机镜像可以被存储到多种存储上,比如简单的文件存储或者对象存储: Image identifiers:一个Image URL,格式:<GlanceServerLocation>/images/<ID> Image status:(

EC2 2.6.18 Xen 3.1.0 kernel(英文)

This is a Xenified version of the 2.6.18 Linux kernel, it includes the patch for the recent 'vmsplice' root exploit(CVE-2008-0600) - along with statically linked Xen drivers. Submitted By:Attila@AWS  AMI ID:aki-9b00e5f2AMI Manifest:ec2-public-images/

关于secuCRT使用EC2的private key的解决办法(英文)

Unfortunately, there's not an easy way to import one of these keys for use with SecureCRT at the moment. I'll add a feature request for the capability of easily importing such keys for use with SecureCRT, but in the meantime, you might be interested

EC2是不是没有WIN2003中文版本?

问题描述 EC2是不是没有WIN2003中文版本?英文看得头大了. 解决方案 解决方案二:另外想问一个问题,EC2可以切换操作系统吗?英文版WIN2003要支持简体中文怎么操作呢?解决方案三:英文版可能可以安装中文语言包或者新启动一个支持多语言版本的windows(在选择AMI时查找multi),然后把老机器的数据复制过去.解决方案四:语言包不知怎么安装了哟上图是腾讯的云主机,系统中文的,里面部分是英文的,搞不懂了.解决方案五:EC2的多语言版的设备管理器也都是英文