问题描述
我想使用 AWS 运行数据分析,这可能需要几天时间.我已经设置了一个系统,其中 Spot 实例将重新加载相同的 EBS 卷,以便它可以在终止后恢复分析.到目前为止,我已经让它工作了,我可以生成一个持久的 Spot 请求,并让分析继续运行,并在 Spot 实例终止后继续,直到它完成.
I want to run data analysis using AWS that'll probably take a few days. I've setup a system where spot instances will reload the same EBS volume so it can resume the analysis after a termination. So far I've got it working where I can just generate a persistent spot request and have the analysis keep running and continue after spot instance terminations until it is done.
但我也希望现货实例在分析完成后取消持久的现货实例请求.有没有办法从现场实例中获取请求 ID?
But I also want the spot instance to cancel the persistent spot instance request when the analysis is finished. Is there anyway to get the request ID from within the spot instance?
推荐答案
从 EC2 元数据中无法获得 Spot 实例信息.但是,实例 ID 是.
The spot instance information is not available from the EC2 metadata. However, the instance ID is.
- 从 EC2 元数据中获取实例 ID.
- 使用DescribeInstances(或
ec2-describe-instances
,或aws ec2 describe-instances
获取实例的实例信息. - 在实例信息中是
spotInstanceRequestId
,这是您要查找的 Spot 实例请求 ID.
- Get the Instance ID from the EC2 metadata.
- Use DescribeInstances (or
ec2-describe-instances
, oraws ec2 describe-instances
to get the instance information for the instance. - Within the instance information is
spotInstanceRequestId
which is the spot instance request ID you're looking for.
这篇关于AWS:取消 Spot 实例内的 Spot 实例请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!