“c4.2xlarge”类型的实例需要虚拟化类型“hvm”

时间:2016-05-23 13:40:29

标签: amazon-web-services amazon-ec2

我是初学者。

尝试使用 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")

有谁能建议我哪里出错了。 请帮忙出来。

1 个答案:

答案 0 :(得分:4)

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

  

Linux Amazon Machine Images使用两种类型的虚拟化之一:半虚拟(PV)或硬件虚拟机(HVM)。 PV和HVM AMI之间的主要区别在于它们的启动方式以及它们是否可以利用特殊的硬件扩展(CPU,网络和存储)来获得更好的性能。

     

为了获得最佳性能,我们建议您在启动实例时使用当前生成实例类型和HVM AMI。

您使用的AMI ID是半虚拟ID,因此只会在older generations of EC2 instances上运行。