gpt4 book ai didi

amazon-web-services - AWS EC2 - 使用运行实例附加更大的卷

转载 作者:行者123 更新时间:2023-12-04 12:48:07 26 4
gpt4 key购买 nike

我在使用 aws ec2 run-instances 在单个命令中启动 EC2 实例和增加根分区的大小时遇到​​了困难。 :

aws ec2 run-instances \
--image-id ami-0b33d91d \
--count 1 \
--instance-type m3.2xlarge \
--key-name my_key \
--security-group-ids "sg-xxxxxxx" \
--ebs-optimized \
--block-device-mapping "[ { \"DeviceName\": \"/dev/sda1\", \"Ebs\": { \"VolumeSize\": 120 } } ]"

实例启动,我可以在控制台中看到列出的新 120GB 卷(虽然不是 root),但随后实例立即停止(不终止)。我尝试根据 these conventions 重命名 DeviceName 属性, 这是一个临时实例,我将启动它,做一些事情,然后终止。也许我需要运行 create-volume首先,然后用一系列单独的命令附加它? AWS 文档似乎到处都是,我找不到明确的解释,尽管我遇到了一些链接 herehere . This SO question建议调整分区大小,但我不确定这是否是我需要做的。据我所知, m3.2xlarge实例类型有 EBS 可用。我是否错误地命名了分区?此配置中的某些内容是否导致实例停止?

编辑

实例自行停止后,我收到了作为对 describe-instances 的响应的一部分:
"BlockDeviceMappings": [
{
"DeviceName": "/dev/xvda",
"Ebs": {
"Status": "attached",
"DeleteOnTermination": true,
"VolumeId": "vol-xxxx",
"AttachTime": "2017-03-05T00:57:23.000Z"
}
},
{
"DeviceName": "/dev/sda1",
"Ebs": {
"Status": "attached",
"DeleteOnTermination": true,
"VolumeId": "vol-xxxx",
"AttachTime": "2017-03-05T00:57:23.000Z"
}
}
],
"Architecture": "x86_64",
"StateReason": {
"Message": "Client.InstanceInitiatedShutdown: Instance initiated shutdown",
"Code": "Client.InstanceInitiatedShutdown"
},
"RootDeviceName": "/dev/xvda",
"VirtualizationType": "hvm",
"AmiLaunchIndex": 0

最佳答案

我认为您遇到了与此 SO 问题相同的问题:

https://serverfault.com/questions/615188/aws-t1-to-t2-migration-client-instanceinitiatedshutdown-on-new-t2-instance

您的实例是 HVM 实例并希望使用 /dev/xvda作为根设备。但是,您指定的是 /dev/sda1 .这是 (a) 创建一个辅助卷,然后 (b) 阻止实例启动,因为它是与 PV 相关的设备而不是 HVM。

因此,作为解决方案,请使用 /dev/xvda作为设备名称。像下面的命令行:

aws ec2 run-instances \
--image-id ami-0b33d91d \
--count 1 \
--instance-type m3.2xlarge \
--key-name my_key \
--security-group-ids "sg-xxxxxxx" \
--ebs-optimized \
--block-device-mapping "[ { \"DeviceName\": \"/dev/xvda\", \"Ebs\": { \"VolumeSize\": 120 } } ]"

关于amazon-web-services - AWS EC2 - 使用运行实例附加更大的卷,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42590215/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com