EC2 上的 LAMP 服务器(Amazon Linux 微型实例)

发布于 2024-12-05 01:43:06 字数 226 浏览 2 评论 0原文

我启动了一个基本 32 位 Amazon Linux AMI 实例,其根设备有 8GB 卷。如果我终止它,EBS 卷也会被销毁。我想知道的是,如果服务器崩溃,我的数据(例如apache文档根目录或MySQL数据)是否受到保护?很多教程似乎都表明应该创建另一个 EBS 卷并将我的数据存储在该卷上,但我真的不明白为什么需要两个 EBS 卷?

或者当前的设置适合​​ Web 服务器设置吗?

非常感谢您的帮助!

I've launched an instance of the Basic 32-bit Amazon Linux AMI which has an 8GB volume as it's root device. If I terminate it, the EBS volume is destroyed as well. What I'd like to know is whether or not my data is protected (for example, the apache document root, or MySQL data) if the server crashes? A lot of tutorials seem to indicate that another EBS volume should be created and my data stored on that, but I'm not really seeing why two EBS volumes are needed?

Or is the current setup okay for a web server setup?

Many thanks in advance for your help!

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

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

发布评论

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

评论(2

花开浅夏 2024-12-12 01:43:06

当您启动 EC2 实例时,根卷是短暂的 - 也就是说,当实例终止时,根卷将被销毁**(带走您放入其中的任何数据)。无论您如何对该临时卷进行分区以及将数据存放在何处,都无关紧要 - 当它被破坏时,该卷中包含的所有内容都会丢失。

因此,如果卷中的数据完全是暂时的,并且下次需要时可以从其他地方完全恢复/检索,那就没有问题;终止该实例,然后启动一个新实例并重新获取继续工作所需的数据。

但是,如果数据不是瞬态的,并且需要持久化,以便在实例崩溃后可以继续工作(所谓崩溃,我的意思是终止实例或以其他方式使其无法操作和不可恢复),那么您的数据一定不能在根卷上,但应该位于附加到实例的另一个 EBS 卷上。如果该实例终止或不可挽回地中断,您的数据在其他卷上是安全的 - 然后可以将其重新附加到新实例以继续工作。

** 例外情况是您的实例由 EBS 支持并且您交换了根卷 - 在这种情况下,根卷在实例终止后会被保留,因为它不是 AMI 在您启动时创建的“包​​”的一部分它。

When you spin an EC2 instance up, the root volume is ephemeral - that is, when the instance is terminated, the root volume is destroyed** (taking any data you put there with it). It doesn't matter how you partition that ephemeral volume and where you tuck your data on it - when it is destroyed, everything contained in that volume is lost.

So if the data in the volume is entirely transient and fully recoverable/retrievable from somewhere else the next time you need it, there's no problem; terminate the instance, then spin a new one up and re-acquire the data you need to carry on working.

However, if the data is NOT transient, and needs to be persisted so that work can carry on after an instance crash (and by crash, I mean something that terminates the instance or otherwise renders it inoperable and unrecoverable) then your data MUST NOT be on the root volume, but should be on another EBS volume which is attached to the instance. If and when that instance terminates or breaks irretrievably, your data is safe on that other volume - it can then be re-attached to a new instance for work to continue.

** the exception is where your instance is EBS-backed and you swapped root volumes - in this case, the root volume is left behind after the instance terminates because it wasn't part of the 'package' created by the AMI when you started it.

沙沙粒小 2024-12-12 01:43:06

如果您的服务器损坏并且无法启动它,则需要另一个卷。在这种情况下,您只需删除初始服务器,创建第二个服务器并将附加存储附加到新服务器。您无法将一台服务器的根卷附加到另一台服务器。

The other volume would be needed in case your server gets broken and you cannot start it. In such case you would just remove initial server, create a second one and attach the additional storage to the new server. You cannot attach root volume of one server to another.

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