Amazon EC2云计算_第1页
Amazon EC2云计算_第2页
Amazon EC2云计算_第3页
Amazon EC2云计算_第4页
Amazon EC2云计算_第5页
已阅读5页,还剩25页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Amazon Elastic Compute CloudGetting Started GuideAPI Version 2010-08-31Amazon Elastic Compute Cloud: Getting Started GuideCopyright 2010 Amazon Web Services LLC or its affiliates. All rights reserved.Amazon Elastic Compute Cloud Getting Started GuideTable of ContentsGet Started with EC2 . 1Sign Up for EC2 . 2Launch an Instance . 3Connect to Your Linux/UNIX Instance . 9Connect to Your Windows Instance . 16Terminate Your Instance . 19Where Do I Go from Here? . 20Please Provide Feedback . 26About This Guide . 27Amazon Elastic Compute Cloud Getting Started GuideGet Started with EC2Amazon Elastic Compute Cloud (Amazon EC2) is a web service that enables you to launch and manageLinux/UNIX and Windows server instances in Amazons data centers.You can get started with AmazonEC2 by following the tasks shown in the following diagram.Youll primarily use the AWS ManagementConsole, a point-and-click web-based interface.This guide walks you through launching and connecting to your first Amazon EC2 instance.API Version 2010-08-311Amazon Elastic Compute Cloud Getting Started GuideSign Up for EC2To use Amazon EC2, you need an AWS account. If you dont already have one, youll be prompted tocreate one when you sign up for Amazon EC2. Signing up for Amazon EC2 also automatically signs youup for Amazon Simple Storage Service and Amazon Virtual Private Cloud, which are closely integratedwith Amazon EC2.Youre not charged for any of the services unless you use them.To sign up for Amazon EC21. Go to /ec2 and click Sign Up for Amazon EC2.2. Follow the on-screen instructions.Part of the sign-up procedure involves receiving a phone call and entering a PIN using the phone keypad.API Version 2010-08-312Amazon Elastic Compute Cloud Getting Started GuideLaunch an InstanceNow that youre signed up for Amazon EC2, youre ready to launch an instance using the AWS ManagementConsole.ImportantThe instance youre about to launch will be live (and not running in a sandbox).You will incur thestandard Amazon EC2 usage fees for the instance until you terminate it in the last task in thistutorial.The total charges will be minimal (typically less than a dollar). For more information aboutAmazon EC2 usage rates, go to the Amazon EC2 product page.To launch an instance1. Start the launch wizard:a. From the AWS Management Console, click Sign in to the AWS Console and log in with thee-mail address and password you used when signing up for Amazon EC2.API Version 2010-08-313Amazon Elastic Compute Cloud Getting Started GuideTipIf you pause for a long period of time during this procedure, the AWS ManagementConsole automatically logs you out.To stay logged in while you work through this tutorial,click Settings in the top right corner of the console window and clear the Sign out oninactivity check box.b. From the Amazon EC2 Console Dashboard, click Launch Instance to start the Request InstancesWizard.2. Choose an AMI:An Amazon Machine Image (AMI) contains all the information needed to create a new instance of aserver. For example, an AMI might contain all the software to act as a web server (e.g., Linux, Apache,and your web site), or all the software to act as a Windows database server (e.g., Windows and SQLServer).The first page of the wizard displays a list of basic AMIs on the Quick Start tab. Select either the Basic 64-bit Amazon Linux AMI, or the Getting Started on Microsoft WindowsServer 2008 AMI.API Version 2010-08-314Amazon Elastic Compute Cloud Getting Started Guide3. Accept the default instance details:After you select an AMI, the wizard steps to the Instance Details page. This is where you controlsettings such as the number and size of instances to launch (in this tutorial youll launch a singlelarge instance). The default settings on this page of the wizard and the next two pages are what we want, sojust click Continue on each page.4. Create a key pair:A key pair is a security credential similar to a password, which you use to securely connect to yourinstance once its running. If youre new to Amazon EC2 and havent created any key pairs yet, whenthe wizard displays the Create Key Pair page, the Create a new Key Pair button is selected bydefault. We assume youll want a new key pair.a. On the Create Key Pair page, enter a name for your key pair (e.g., GSG_Keypair). This will bethe name of the private key file associated with the pair (with a .pem extension).API Version 2010-08-315Amazon Elastic Compute Cloud Getting Started Guideb. Click Create & Download your Key Pair.Youre prompted to save the private key from the key pair to your system.c. Save the private key in a safe place on your system. Note the location because youll need touse the key soon to connect to the instance.5. Create a security group:A security group defines firewall rules for your instances.These rules specify which incoming networktraffic should be delivered to your instance (e.g., accept web traffic on port 80). All other traffic isignored.You can modify rules for a group at any time. The new rules are automatically enforced forall running instances.If youre new to Amazon EC2 and havent set up any security groups yet, when the wizard displaysthe Configure Firewall page, the Create a new Security Group button is selected by default, andtypical firewall rules are already selected. Use the default rules for this tutorial.a. On the Configure Firewall page of the wizard, enter a name for your security group and adescription. The following image shows the default rules for a Linux/UNIX instance (SSH andHTTP access).API Version 2010-08-316Amazon Elastic Compute Cloud Getting Started GuideThe following image shows the default rules for a Windows instance (RDP, MS SQL Server,and HTTP access).b. Click Continue.CautionThe security group youve created enables all IP addresses to access your instance. Thisis acceptable for the short exercise in this tutorial, but its unsafe for production environments.In production, youll authorize only a specific IP address or range of addresses to accessyour instance.API Version 2010-08-317Amazon Elastic Compute Cloud Getting Started Guide6. Review your settings and launch the instance:After you configure the firewall, the wizard steps to the Review page where you can review thesettings and launch the instance.a. Click Launch.A confirmation page is displayed to let you know your instance is launching.b. Click Close to close the confirmation page, and then click Instances in the navigation pane toview your instances status. It takes a short time for an instance to launch. The instances statuswill be pending while its launching.After a short period, your instances status switches to running.You can click Refresh or F5 torefresh the display.c. Record the public DNS name for your instance because youll need it for the next task.Once your instances status is running, you can connect to it. If you launched a Linux/UNIX instance,see Connect to Your Linux/UNIX Instance (p. 9). If you launched a Windows instance, see Connectto Your Windows Instance (p. 16).API Version 2010-08-318Amazon Elastic Compute Cloud Getting Started GuideConnect to Your Linux/UNIXInstanceTopics Connecting from a Linux/UNIX Machine (p. 10) Connecting from a Windows Machine (p. 11)API Version 2010-08-319Amazon Elastic Compute Cloud Getting Started GuideConnecting from a Linux/UNIX MachineUse the ssh command to connect to your Linux/UNIX instance from a Linux/UNIX machine.NoteMost Linux and UNIX machines include an SSH client by default. If yours doesnt, the OpenSSHproject provides a free implementation of the full suite of SSH tools. For more information, go to.To use SSH to connect1. In a command line shell, change directories to the location of the private key file that you createdwhen you launched the instance.2. Use the chmod command to make sure your private key file isnt publicly viewable. For example, ifyour file were GSG_Keypair.pem, you would enter:chmod 400 GSG_Keypair.pem3. Connect to your instance using the instances public DNS name (which you should have recordedearlier). For example, if the key file is GSG_Keypair.pem and the instances DNS name , use the following command.ssh -i GSG_Keypair.pem TipThe AMI we launched in this exercise requires you to log in to your instance as ec2-user.Some AMIs let you log in as root.Youll see a response like the following.The authenticity of host (3)cant be established.RSA key fingerprint is fc:8d:0c:eb:0e:a6:4a:6a:61:50:00:c4:d2:51:78:66.Are you sure you want to continue connecting (yes/no)? yes4. Enter yes.Youll see a response like the following.Warning: Permanently added (RSA) to the list of known hosts.Youre now logged in as ec2-user and can work with the instance like you would any normal server. Ifyou need to run a command as root, you must prefix the command with sudo. For example:sudo /bin/cat /etc/image-idNormally youd continue using the instance. However, for the purposes of this tutorial, were going toshow you how to terminate the instance immediately. Jump to Terminate Your Instance (p. 19).API Version 2010-08-3110Amazon Elastic Compute Cloud Getting Started GuideConnecting from a Linux/UNIX MachineConnecting from a Windows MachineTo connect to your Linux/UNIX instance from a Windows machine, you use an SSH client. The followinginstructions assume that youre using PuTTY, a free SSH client for Windows machines.Getting PuTTYTo download and install PuTTY Go to .uk/sgtatham/putty/ and follow the instructions there.NoteOther tools in the PuTTY suite are PuTTYgen, a key generation program, and pscp, a securecopy command line tool. The different PuTTY tools are separate applications.You can installthem separately or install the entire suite with a simple Windows installer.The following instructionsassume youve installed the entire suite and can access all the components from the WindowsStart menu.Converting Your Private KeyPuTTY does not natively support the private key format generated by Amazon EC2. Fortunately, PuTTYhas a tool called PuTTYgen, which can convert keys to the required PuTTY format.To convert your private key1. Start PuTTYgen (e.g., from the Start menu, click All Programs PuTTY PuTTYgen).2. Click Load and browse to the location of the private key file that you want to convert (e.g.,GSG_Keypair.pem). By default, PuTTYgen displays only files with extension .ppk; youll need tochange that to display files of all types in order to see your .pem key file. The private key file mustend with a newline character or PuTTYgen cannot load it correctly.3. Select your .pem key file and click Open.PuTTYgen displays the following message.API Version 2010-08-3111Amazon Elastic Compute Cloud Getting Started GuideConnecting from a Windows MachineWhen you click OK, PuTTYgen displays a dialog box with information about the key you loaded,such as the public key and the fingerprint.The keys that Amazon EC2 generates are 1024-bit SSH-2RSA keys.4. Click Save private key to save the key in PuTTYs format.PuTTYgen asks if you want to save the key without a passphrase.5. Click Yes.NoteA passphrase on a private key is an extra layer of protection, so even if your private key isdiscovered, it will not be usable without the passphrase.The downside to using a passphraseis that it makes automation harder because human intervention is needed to log on to aninstance, or copy files to an instance. For this exercise, were not using a passphrase.6. Name the key with the same name you used for the key pair (e.g., GSG_Keypair). PuTTY automaticallyadds the .ppk file extension.Your private key is now in the correct format for use with PuTTY.You can now connect to your instanceusing PuTTYs SSH client.Connecting Using PuTTY SSHYoull connect by starting a PuTTY SSH session.To use SSH to connect1. Start PuTTY (e.g., from the Start menu, click All Programs PuTTY PuTTY).A dialog box opens with a Category menu on the left side. On the right side, the basic options foryour PuTTY session are displayed.2. In the Host Name field, enter the public DNS name of your instance (which you should have recordedearlier).You can optionally prefix the DNS name with ec2-user to automatically log in as ec2-userwhen the session opens.API Version 2010-08-3112Amazon Elastic Compute Cloud Getting Started GuideConnecting Using PuTTY SSH3. In the Category menu, under Connection, click SSH, and then Auth.The options controlling SSH authentication are displayed.4. Click Browse and navigate to the PuTTY private key file you generated in the preceding section.API Version 2010-08-3113Amazon Elastic Compute Cloud Getting Started GuideConnecting Using PuTTY SSH5. Click Open.An SSH session window opens and PuTTY displays a security alert asking if you trust the host youreconnecting to.6. Click Yes.7. In the SSH session window, log in as ec2-user if you didnt as part of starting the SSH session.TipThe AMI we launched in this exercise requires you to log in to your instance as ec2-user.Some AMIs let you log in as root.NoteIf you specified a passphrase when you converted your private key to PuTTYs format, youmust provide that passphrase when you log in to the instance.Youre now logged in as ec2-user and can work with the instance like you would any normal server. Ifyou need to run a command as root, you must prefix the command with sudo. For example:sudo /bin/cat /etc/image-idAPI Version 2010-08-3114Amazon Elastic Compute Cloud Getting Started GuideConnecting Using PuTTY SSHNormally youd continue using the instance. However, for the purposes of this guide, were going to showyou how to terminate the instance immediately. Jump to Terminate Your Instance (p. 19).API Version 2010-08-3115Amazon Elastic Compute Cloud Getting Started GuideConnecting Using PuTTY SSHConnect to Your Windows InstanceTo connect to a Windows instance, you must retrieve the initial administrator password first, and thenuse it with Remote Desktop.Youll need the contents of the private key file that you created when youlaunched the instance (e.g., GSG_Keypair.pem).To connect to your Windows instance1. Retrieve the initial administrator password:a. Navigate to the directory where you stored the private key file when you launched the instance.b. Open the file in a text editor and copy the entire contents (including the first and last lines, whichcontain BEGIN RSA PRIVATE KEY and END RSA PRIVATE KEY).c. Go to the AWS Management Console and locate the instance on the Instances page.d. Right-click the instance and select Get Windows Password.The Retrieve Default Windows Administrator Password dialog box is displayed (it might takea few minutes after the instance is launched before the password is available).API Version 2010-08-3116Amazon Elastic Compute Cloud Getting Started Guidee. Paste the contents of the private key file into the Private Key field.f. Click Decrypt PasswordThe console returns the default administrator password for the instance.g. Save the password.You will need it to connect to the instance.2. Connect to the instance using Remote Desktop:a. Start the Remote Desktop application (e.g., from the Start menu, point to All Programs Accessories, and then click Remote Desktop Connection).API Version 2010-08-3117Amazon Elastic Compute Cloud Getting Started GuideNoteMost modern Windows operating systems from Windows XP onward already includethe Remote Desktop application. If youre using an old version of Windows, you candownload the Remote Desktop application from the Microsoft web site.b. Enter the public DNS name of the instance (which you should have recorded earlier) and clickConnect.c. Log in using Administrator as the username and the administrator password you got in theprevious task as the password.Youre now connected to your instance.You can work with it like you would any Windows server.CautionAfter you connect to any new Windows instance youve just launched, we recommend you changethe Windows administrator password from the default value.Normally youd continue using the instance. However, for the purposes of this tutorial, were going toshow you how to terminate the instance immediately. Jump to Terminate Your Instance (p. 19).API Version 2010-08-3118Amazon Elastic Compute Cloud Getting Started GuideTerminate Your InstanceAs soon as your instance starts to boot, youre billed for each hour or partial hour that you keep theinstance running (even if the instance is idle). Once youve decided that you no longer need the instance,you can terminate it.NoteYou cannot restart a terminated instance. However, you can launch additional instances of thesame AMI.To terminate an instance1. In the AWS Management Console, locate the instance in your list of instances on the Instancespage.2. Right-click the instance, and then click Terminate.3. Click Yes,Terminate when prompted for confirmation.Amazon EC2 begins terminating the instance. As soon as the instance status changes to shuttingdown or terminated, you stop incurring charges for that instance.Congratulations! You successfully launched, connected to, and terminated an instance. For moreinformation about Amazon EC2 and how to continue, see Where Do I Go from Here? (p. 20).API Version 2010-08-3119Amazon Elastic Compute Cloud Getting Started GuideWhere Do I Go from Here?Topics AWS Account and Security Credentials (p. 20) Other Ways to Access Amazon EC2 (p. 20) Designing Your Application for the Cloud (p. 21) Learn More about Amazon EC2 (p. 21) Amazon EC2 Resources (p. 24)Amazon EC2 is a rich service offering many things we havent covered in this guide, such as creatingyour own AMIs, using persistent file storage, monitoring instance health, load balancing, and virtual privatenetworking. This section provides links to additional resources, which will help you deepen yourunderstanding and use of Amazon EC2.AWS Account and Security CredentialsSo far you signed up for the service, got an AWS account and security credentials, and then completeda short exercise of the essential product functions. Following the exercise, we recommend you checkwith an administrator or co-worker in your organization to determine if they already have an AWS accountand security credentials for you to use in future interactions with AWS.If youre an account owner or administrator and would like to know more about AWS Identity and AccessManagement, go to the product description at /iam or to the technical documentationat Using AWS Identity and Access Management.Other Ways to Access Amazon EC2This guide has shown you how to launch and terminate an instance using the AWS Management Console.You can continue using Amazon EC2 through the console, or try one of the other interfaces.Continue Using the ConsoleThe AWS Management Console includes many other functions besides just launching and terminatinginstances. To learn more about how to use Amazon EC2 through the console, go to the Amazon ElasticAPI Version 2010-08-3120Amazon Elastic Compute Cloud Getting Started GuideAWS Account and Security CredentialsCompute Cloud User Guide. The console also has online Help to assist you (just click the Help button inthe console).Use the Command Line InterfaceTo get started with Amazon EC2s Java-based command line interface, go to the Getting Started sectionin the Amazon Elastic Compute Cloud User Guide. These command line tools are a fast way to executeall the EC2 functions without coding to the API or using a library.Use an Existing LibraryIf you prefer to use Amazon EC2 through a programmatic interface, there are libraries and resourcesavailable for the following languages: Java PHP Python Ruby Windows and .NETFor libraries and sample code in all languages, go to Amazon EC2 Sample Code & Libraries.Code Directly to the Web Service APIIf you want to write code directly to the Amazon EC2 SOAP or Query API, go to the Amazon ElasticCompute Cloud Developer Guide.The guide describes how to create and authenticate API requests, andhow to use Amazon EC2 through the APIs. For a complete description of all the API actions, go to theAmazon Elastic Compute Cloud API Reference.Designing Your Application for the CloudAWS solutions architects and evangelists have written white papers to help you design your applicationso its fault tolerant, scalable, and elastic. For more information, go to AWS Cloud Computing Whitepapers.Learn More about Amazon EC2This section lists additional features of Amazon EC2 and where to get more information.You can alsofind additional information about Amazon EC2 in the Amazon EC2 Articles & Tutorials area of the AWSweb site.Creating Your Own AMIsOne of the first tasks youll want to do after completing this guide is to create one or more custom AMIs.You can modify Amazon AMIs or public AMIs as needed (a process called rebundling). For generalinformation about AMIs, go to AMIs and to Preparing and Creating AMIs in the Amazon Elastic ComputeCloud User Guide.You can choose between Amazon S3 or Amazon Elastic Block Store as the root device for your AMI (fora brief description of Amazon EBS, see Amazon Elastic Block Store (p. 23) later in this section). Werecommend using instances backed by Amazon EBS, because they launch faster and use persistentAPI Version 2010-08-3121Amazon Elastic Compute Cloud Getting Started GuideUse the Command Line Interfacestorage. For more information, go to AMIs Backed by Amazon EBS in the Amazon Elastic Compute CloudUser Guide.Instance TypesTo meet the needs of different organizations and applications, Amazon EC2 instances are available indifferent sizes and CPU/memory configurations. For more information, go to Instances in the AmazonElastic Compute Cloud User Guide.TagsYou can add optional metadata to your instances, AMIs, and other EC2 resources to help you categorizeand manage them. For more information, go to Using Tags in the Amazon Elastic Compute Cloud UserGuide.Elastic IP AddressesYou might want to have static IP addresses for your instances. Amazon EC2 provides elastic IP addressesthat can be dynamically remapped to different instances. For more information, go to Elastic IP Addressesin the Amazon Elastic Compute Cloud User Guide.Security GroupsYou might be concerned about keeping others from accessing your instances, both inside and outsidethe Amazon network.You can create other security groups (beyond the default group we used in thisguide) to meet your security requirements. For more information, go to Network Security Concepts in theAmazon Elastic Compute Cloud User Guide.Availability ZonesYou might want to build a geographically dispersed, fault tolerant architecture on Amazon EC2.You canplace instances in different geographic regions and isolate instances within those regions using AvailabilityZones. This provides geographic flexibility and affordable fault tolerance. For more information, go toRegion and Availability Zone Concepts in the Amazon Elastic Compute Cloud User Guide.Amazon LinuxAWS provides Amazon Linux AMIs, which are supported and maintained Linux images optimized for theEC2 environment. For more information, go to Amazon Linux AMI.Amazon EC2 Running WindowsAmazon EC2 can run Microsoft Windows Server, with or without Microsoft SQL Server. For moreinformation, go to the Amazon EC2 Running Microsoft Windows Server and SQL Server page. Also, goto Windows Instance Types in the Amazon Elastic Compute Cloud User Guide.Reserved InstancesYou might want to run a set of full-time or nearly full-time instances but also bring down your costs.Amazon EC2 supports an additional pricing option that enables you to make a low one-time payment foreach instance to reserve and receive a significant discount on the hourly usage charge for that instance.For more information, go to On-Demand and Reserved Instances and to Reserving Amazon EC2 Instancesin the Amazon Elastic Compute Cloud User Guide.API Version 2010-08-3122Amazon Elastic Compute Cloud Getting Started GuideInstance TypesSpot InstancesIf youre flexible about when you need instances and want to bring down your costs, Amazon EC2 letsyou bid for unused Amazon EC2 capacity and run your instances for as long as your bid exceeds thecurrent Spot Price. For more information, go to the Amazon EC2 Spot Instances product page andIntroduction to Spot Instances.Amazon Elastic Block StoreYou might need more space than is provided on the instance, or you might need a permanent storagesolution. Amazon Elastic Block Store enables you to create volumes that can be mounted as block devicesby Amazon EC2 instances. Amazon EBS volumes behave like raw unformatted external block devices,and they persist past the life of an Amazon EC2 instance. For more information, go to the Amazon ElasticBlock Store product page. Also go to Using Amazon Elastic Block Store in the Amazon Elastic ComputeCloud User Guide.Monitoring InstancesYou might need a solution for monitoring your instances. Amazon CloudWatch is a monitoring servicefor Amazon EC2 that is designed to gather, aggregate, store, and retrieve metrics. For more information,go to the Amazon CloudWatch product page and the Amazon CloudWatch Developer Guide.Load BalancingYou might need a solution for load balancing requests to your instances. Elastic Load Balancing offersthe ability to evenly spread requests across your running Amazon EC2 instances. For more information,go to the Elastic Load Balancing product page and the Elastic Load Balancing Developer Guide.Automatically Scaling InstancesYou might want to automatically scale up and down the number of instances you use. Auto Scalingenables you to automatically increase or decrease the number of running Amazon EC2 instances inresponse to your web applications usage and the configuration you define. For more information, go tothe Auto Scaling product page and the Amazon Auto Scaling Developer Guide.Micro InstancesAmazon EC2 offers micro instances, which provide a small amount of consistent CPU resources andallow you to burst CPU capacity when additional cycles are available. They are well suited for lowerthroughput applications and web sites that consume significant compute cycles periodically. For moreinformation, go to Micro Instance Concepts in the Amazon Elastic Compute Cloud User Guide.Cluster Compute InstancesAmazon EC2 offers cluster compute instances for your High-Performance Computing (HPC) applications.These instances provide you with high-bandwidth, low-latency inter-node communications for advancedcomputational applications such as computational fluid dynamics, computational biology, and materialsresearch. For more information, go to Cluster Compute Instance Concepts in the Amazon Elastic ComputeCloud User Guide.API Version 2010-08-3123Amazon Elastic Compute Cloud Getting Started GuideSpot InstancesPrivate InstancesAmazon VPC lets you launch private instances and connect them directly to your own data center usinga VPN connection. For more information, go to the Amazon VPC product page and the Amazon VirtualPrivate Cloud Getting Started Guide.Public Data SetsAmazon EC2 provides a repository of public data sets, such as the mapping of the human genome andthe US census data, that you can seamlessly integrate into your AWS cloud-based applications. For moreinformation, go to the Public Data Sets on AWS page. Also go to Using Public Data Sets in the AmazonElastic Compute Cloud User Guide.Amazon EC2 ResourcesThe following table lists related resources that youll find useful as you work w

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论