如何将 2 个额外的 EBS 附加到自动缩放组中新旋转的 EC2 实例?

发布于 2025-01-14 01:21:48 字数 153 浏览 1 评论 0原文

在自动缩放组中,我有一个 EC2 实例(具有两个 EBS 存储),该实例可能会因任何故障而终止,并且一个新的 EC2 实例会在自动缩放组内的位置旋转。 我的问题是如何将附加到旧 EC2 实例的两个 EBS 存储附加到新 EC2 实例。 如果这是手动过程,可以提供 terraform 的参考。

In autoscaling group, I have an EC2 instance (with two EBS storage) which could terminate due to any fault and a new EC2 instance is spun in it's place inside the autoscaling group.
My question is how the two EBS storage attached to old EC2 instance be attached to new EC2 instance.
if this is manual process, could reference to terraform be provided.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

裸钻 2025-01-21 01:21:48

@rukan我猜你需要将“DeleteOnTermination”值设置为 false,因为你需要旧实例的 EBS 来创建新创建的实例。

参考:

https://docs.aws.amazon.com/autoscaling/ ec2/APIReference/API_Ebs.html

https://francescoboffa.com/aws-stateful-service-ebs/

更新:

我尝试对您的要求进行一些研究,我可以得出结论,没有标准方法我们可以在 AWS 自动缩放组中重复使用 EBS 卷。此外,不建议这样做,因为自动缩放组会启动多个 EC2 实例。每个 EBS 卷只能附加到单个 EC2 实例。目前,我建议使用 AWS EFS 而不是 EBS。

但是,如果这必须满足 EBS 的要求,那么我们需要考虑一些复杂的逻辑,编写某种启动脚本,将卷与 EC2 实例关联起来,然后安装它。您可以参考此答案

参考:

https://serverfault.com/questions/831974/can-我-重新使用-ebs-volume-with-aws-asg

@rukan I guess you need to make 'DeleteOnTermination' value as false, as you would need EBS of old instances for newly created one.

Reference :

https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_Ebs.html

https://francescoboffa.com/aws-stateful-service-ebs/

Update :

I tried to do some research on your requirement and I can conclude my answer that there is no standard method where we can re-use EBS volume in AWS auto-scaling group. Moreover It is not recommended one, as autoscaling groups start multiple EC2 instances. Each EBS volume can only be attached to a single EC2 instance. For now, I can suggest to use AWS EFS instead of EBS.

But, if this is must do requirement with EBS, then we need think of some complex logic where writing some kind of startup script which associated the volume with the EC2 instance then mounted it. You can refer this answer

Reference :

https://serverfault.com/questions/831974/can-i-re-use-an-ebs-volume-with-aws-asg

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文