2016-05-23 57 views
-2

我是初學者。'c4.2xlarge'類型的實例需要虛擬化類型'hvm'

嘗試使用com.amazonaws.services.ec2.model.RunInstancesRequest亞馬遜服務啓動EC2實例(c4.2xlarge)時。

我得到了以下錯誤。

2016-05-23 13:13:19 ERROR org.codehaus.groovy.grails.web.errors.GrailsExceptionResolver: 213 - AmazonServiceException occurred when processing request: [POST] /leaseabuse-crawler-manager/instances/start 
Virtualization type 'hvm' is required for instances of type 'c4.2xlarge'. Ensure that you are using an AMI with virtualization type 'hvm'. For more information, see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/virtualization_types.html (Service: AmazonEC2; Status Code: 400; Error Code: InvalidParameterCombination; Request ID: 9c35befc-15ba-4010-b0c6-bf38285369f1). Stacktrace follows: 
com.amazonaws.AmazonServiceException: Virtualization type 'hvm' is required for instances of type 'c4.2xlarge'. Ensure that you are using an AMI with virtualization type 'hvm'. For more information, see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/virtualization_types.html (Service: AmazonEC2; Status Code: 400; Error Code: InvalidParameterCombination; Request ID: 9c35befc-15ba-4010-b0c6-bf38285369f1) 
     at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1369) 
     at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:913) 
     at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:631) 
     at com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:400) 
     at com.amazonaws.http.AmazonHttpClient.executeWithTimer(AmazonHttpClient.java:362) 
     at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:311) 
     at com.amazonaws.services.ec2.AmazonEC2Client.invoke(AmazonEC2Client.java:11093) 
     at com.amazonaws.services.ec2.AmazonEC2Client.runInstances(AmazonEC2Client.java:10618) 
     at com.leaseabuse.devops.AwsService.startInstances(AwsService.groovy:167) 
     at com.leaseabuse.devops.InstancesController.start(InstancesController.groovy:34) 
     at grails.plugin.cache.web.filter.PageFragmentCachingFilter.doFilter(PageFragmentCachingFilter.java:198) 
     at grails.plugin.cache.web.filter.AbstractFilter.doFilter(AbstractFilter.java:63) 
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
     at java.lang.Thread.run(Thread.java:745) 
2016-05-23 13:13:19 DEBUG grails.app.filters.com.leaseabuse.devops.ApiKeyFilters: 128 - Security enabled 

下面是我想使用

RunInstancesRequest runInstancesRequest = new RunInstancesRequest() 
       .withInstanceType(InstanceType.C42xlarge) 
       .withImageId(amiId) 
       .withMinCount(count) 
       .withMaxCount(count) 
       .withSecurityGroupIds("some-group") 
       .withKeyName("Key-name") 

任何人都可以建議我在哪裏,我錯了代碼。 請幫忙出來。

回答

3

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/virtualization_types.html

Linux的亞馬遜機器映像使用兩個中的一個類型的虛擬化:半虛擬化(PV)或硬件虛擬機(HVM)。 PV和HVM AMI之間的主要區別在於它們的啓動方式以及它們是否可以利用特殊的硬件擴展(CPU,網絡和存儲)來獲得更好的性能。

爲了獲得最佳性能,我們建議您在啓動實例時使用當前代實例類型和HVM AMI。

您使用的AMI ID是一個半虛擬ID,因此只能在older generations of EC2 instances上運行。

+0

感謝您的回答@ceejayoz,但我現在應該做什麼。 是我必須創建一個hvm類型的AMI。 –

+0

@SandeepRoniyaar創建一個新的HVM AMI,或堅持仍舊支持PV的舊實例類型。我建議使用HVM方法 - PV代將最終完全消失。 – ceejayoz