简体   繁体   English

如何在 AWS 中备份 EC2 实例并转向低成本替代方案?

[英]How to take a backup of EC2 instance in AWS and move to a low cost alternative?

We have an EC2 instance running in AWS EC2 instance.我们有一个在 AWS EC2 实例中运行的 EC2 实例。 We have our ML algorithms and data that.我们有我们的机器学习算法和数据。 We have also hosted a web-based interface also in that machine.我们还在该机器上托管了一个基于 Web 的界面。

Now there are no new developments happening in that EC2 instance.现在该 EC2 实例中没有新的进展。 We would like to terminate AWS subscription for a short period of time (for the purpose of cost-reduction and exploring new cloud services).我们想在短时间内终止 AWS 订阅(为了降低成本和探索新的云服务)。 Most importantly, we want to be in a position where we can purchase a new EC2 instance with a fresh AWS subscription, use the backup which we take now, and resume all operations (web-backend, SMS services for our app which is hosted in AWS, etc.).最重要的是,我们希望在 position 中,我们可以购买一个新的 AWS 订阅的新 EC2 实例,使用我们现在进行的备份,并恢复所有操作(Web 后端,为我们的应用程序托管的 SMS 服务) AWS 等)。

What is the best way to do it?最好的方法是什么? Is temporary termination of AWS subscription advisable?是否建议暂时终止 AWS 订阅?

There is no concept of an "AWS Subscription".没有“AWS 订阅”的概念。 AWS is charged on-demand, which means you only pay when you use resources. AWS 按需收费,这意味着您只需在使用资源时付费。

If you temporarily do not want the Amazon EC2 instance, you could:如果您暂时不需要 Amazon EC2 实例,您可以:

  • Stop the instance, which is like turning off the power.停止实例,相当于关闭电源。 You will not be charged for the instance, but you will still pay for the disk storage attached to the instance.您无需为实例付费,但您仍需为附加到实例的磁盘存储付费。 You can simply Start the instance again when you wish to use it.当您希望使用它时,您可以简单地再次启动该实例。 You will only be charged while the instance is running.只有在实例运行时才会向您收费。 OR或者
  • Create an image of the instance, then terminate the instance.创建实例的映像,然后终止实例。 This will create an Amazon Machine Image (AMI), which contains a copy of the disks.这将创建一个包含磁盘副本的 Amazon 系统映像 (AMI)。 You can then launch a new Amazon EC2 instance from the AMI when you wish to use it again.然后,当您希望再次使用它时,可以从 AMI 启动一个新的 Amazon EC2 实例。 This is a lower-cost option compared to simply stopping the instance, but it takes more effort to stop/start.与简单地停止实例相比,这是一个成本较低的选项,但停止/启动需要更多的努力。

It is quite common for companies to stop Amazon EC2 instances at night or over the weekend to reduce costs while they are not needed.公司在晚上或周末停止 Amazon EC2 实例以在不需要它们时降低成本是很常见的。

EDIT: Just thought of a third option.编辑:只是想到了第三种选择。 Will test it and be back.将对其进行测试并回来。 Not worth it;不值得; it would involve creating an image from the EC2 instance and then convert that image to a VM image, storing the VM image in S3.这将涉及从 EC2 实例创建映像,然后将该映像转换为 VM 映像,将 VM 映像存储在 S3 中。 There may be some advantages to this, but I do not see them.这可能有一些优点,但我没有看到它们。

I think you have two options, both of them very reasonably priced .我认为您有两种选择,它们的价格都非常合理 If you can separate the data from the operating system, then your best option would be to use an S3 bucket as a file system within the EC2 instance.如果您可以将数据与操作系统分离,那么您最好的选择是使用 S3 存储桶作为 EC2 实例中的文件系统。 Your EC2 instance would use this bucket to store all your "ML algorithms and data" and, possibly, even your "web-based interface".您的 EC2 实例将使用此存储桶来存储您的所有“ML 算法和数据”,甚至可能存储您的“基于 Web 的界面”。 Whenever you decide that you no longer need the processing capacity of the EC2, you would unmount the S3 bucket file system from the EC2 instance and terminate that instance.每当您决定不再需要 EC2 的处理能力时,您将从 EC2 实例中卸载 S3 存储桶文件系统并终止该实例。 After configuring an appropriate lifecycle rule for the S3 bucket, it would transition to Glacier, or even Glacier Deep Archive [you must considerer the different options of long term storage].在为 S3 存储桶配置适当的生命周期规则后,它将过渡到 Glacier,甚至 Glacier Deep Archive [您必须考虑长期存储的不同选项]。 In the future, whenever you want to work with your data again, you would move your data from Glacier back to S3, create a new EC2 instance, install your applications, mount your S3 bucket as a file system and you would have access to all your data.将来,每当您想再次使用数据时,您都可以将数据从 Glacier 移回 S3,创建一个新的 EC2 实例,安装您的应用程序,将您的 S3 存储桶挂载为文件系统,然后您就可以访问所有你的数据。 I think this is your least expensive and shortest recovery time objective option.我认为这是您成本最低、恢复时间最短的客观选择。 To implement this option, look at my answer to this question ;要实施此选项, 请查看我对这个问题的回答 everything you need to use an S3 bucket as a regular folder inside the EC2 instance is there.将 S3 存储桶用作 EC2 实例内的常规文件夹所需的一切都在那里。

The second option provides an integrated solution, meaning the operating system and the data stay together, and allows you to restore everything as it was the day you stopped processing your data.第二个选项提供了一个集成的解决方案,这意味着操作系统和数据保持在一起,并允许您恢复所有内容,就像您停止处理数据的那一天一样。 It's made up of the following cycle:它由以下循环组成:

  1. Shutdown your EC2 and make a note of all the specs [you need them further down].关闭您的 EC2 并记下所有规格 [您需要它们进一步向下]。
  2. Export your instance to a virtual image, vmdk for example, and store it in your S3 bucket.将您的实例导出到虚拟映像,例如 vmdk,并将其存储在您的 S3 存储桶中。 Something like this:像这样的东西:

aws ec2 create-instance-export-task --instance-id i-0d54b0682aa3998a0 --target-environment vmware --export-to-s3-task DiskImageFormat=VMDK,ContainerFormat=ova,S3Bucket=sm-vm-backup,S3Prefix=vms aws ec2 create-instance-export-task --instance-id i-0d54b0682aa3998a0 --target-environment vmware --export-to-s3-task DiskImageFormat=VMDK,ContainerFormat=ova,S3Bucket=sm-vm-backup,S3Prefix=虚拟机

  1. Configure an appropriate lifecycle rule for the S3 bucket so that it transitions to Glacier, or even Glacier Deep Archive.为 S3 存储桶配置适当的生命周期规则,使其过渡到 Glacier,甚至 Glacier Deep Archive。
  2. Terminate the EC2 instance.终止 EC2 实例。
  3. In the future you will need to implement the inverse, so you will need to restore the archived S3 Object [make sure you you can live with the time needed by AWS to do this]将来您将需要执行反向操作,因此您需要恢复存档的 S3 Object [确保您可以忍受 AWS 执行此操作所需的时间]
  4. Import the virtual image as an EC2 AMI, something like this [this is not complete - you will need some more options that you saved above]:将虚拟映像作为 EC2 AMI 导入,如下所示 [这不完整 - 您需要在上面保存的更多选项]:

aws ec2 import-image --disk-containers Format=ova,UserBucket="{S3Bucket=sm-vm-backup,S3Key=vmsexport-i-0a1c382e740f8b0ee.ova}" aws ec2 import-image --disk-containers Format=ova,UserBucket="{S3Bucket=sm-vm-backup,S3Key=vmsexport-i-0a1c382e740f8b0ee.ova}"

  1. Create an EC2 instance based on the image and you're back in business.根据映像创建一个 EC2 实例,您就可以重新开始工作了。

Obviously you should do some trial runs and even automate the entire process if it's something that will be done frequently.显然你应该做一些试运行,甚至自动化整个过程,如果这是经常做的事情。 I have a feeling, based on what you said, that the first option is a better option, provided you can easily install whatever applications they use.根据您所说,我有一种感觉,第一个选项是一个更好的选择,前提是您可以轻松安装他们使用的任何应用程序。

I'm assuming that you launched an EC2 instance from a base Amazon Machine Image and then added your own software and models to it.我假设您从基本 Amazon 系统映像启动了一个 EC2 实例,然后向其中添加了您自己的软件和模型。 As opposed to launched an EC2 instance from an AWS Marketplace offering.与从 AWS Marketplace 产品启动 EC2 实例相反。

The simplest thing to do is to create an Amazon Machine Image (AMI) from your running EC2 instance.最简单的做法是从您正在运行的 EC2 实例创建一个Amazon 系统映像(AMI)。 That will capture the current state of the instance and persist it in your AWS account.这将捕获实例的当前 state 并将其保存在您的 AWS 账户中。 Then you can terminate the instance.然后您可以终止该实例。 Later, when you want to recreate it, launch a new instance, selecting the saved AMI instead of a standard AMI.稍后,当您想要重新创建它时,启动一个新实例,选择保存的 AMI 而不是标准 AMI。

An alternative is to avoid the need to capture machine state at all, by using standard DevOps practices to revision-control everything you need to recreate the state of a running machine.另一种方法是完全避免捕获机器 state,方法是使用标准 DevOps 实践来修订控制重新创建运行机器的 state 所需的一切。

Note that there are costs associated with an AMI, though they are minimal ($0.05 per GB-month of data stored, for example).请注意,与 AMI 相关的成本是最低的(例如,每 GB 月存储的数据 0.05 美元)。

I had contacted AWS customer care regarding this issue.我已就此问题联系了 AWS 客户服务。 Given below is the response I received.以下是我收到的回复。 Please add your comments on which option might be good for me.请添加您对哪个选项可能对我有好处的评论。

Note: I acknowledge the AWS customer care team for their help.注意:我感谢 AWS 客户服务团队的帮助。

I understand that you require some information on cost saving for your Instance since you will not be utilizing the service for a while.我了解您需要一些有关为您的实例节省成本的信息,因为您暂时不会使用该服务。

To assist you with this I would recommend checking out the Instance Stop/Start link here: ==> https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Stop_Start.html .为了帮助您解决此问题,我建议您在此处查看实例停止/启动链接:==> https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Stop_Start.html

When you stop an Instance, you do not lose any data & you are not charged for the resources any further.当您停止实例时,您不会丢失任何数据并且您无需再为资源付费。 However please keep in mind that you will still be charged for any EBS Storage Volumes attached to the stopped Instance(s).但是请记住,您仍需为附加到已停止实例的任何 EBS 存储卷付费。

I also recommend checking out the below links on how you can reduce your costs.我还建议查看以下链接,了解如何降低成本。 ==> https://aws.amazon.com/premiumsupport/knowledge-center/reduce-aws-bill/ ==> https://aws.amazon.com/blogs/compute/10-things-you-can-do-today-to-reduce-aws-costs/ ==> https://aws.amazon.com/premiumsupport/knowledge-center/reduce-aws-bill/ ==> https://aws.amazon.com/blogs/compute/10-things-you-can-立即执行以降低 AWS 成本/

That being said, please note that as I am in the billing department, for the best assistance with the various plans you will require the assistance of our Sales Team.话虽如此,请注意,由于我在计费部门,为了获得各种计划的最佳帮助,您需要我们的销售团队的帮助。

The Sales Team will be able to assist with ways to save while maintaining your configurations.销售团队将能够帮助您在维护配置的同时进行保存。

You will be able to reach the Sales Team here: ==> https://aws.amazon.com/websites/contact-us/ .您可以在此处联系销售团队:==> https://aws.amazon.com/websites/contact-us/

Once you have completed the details in the link, a member of the team will be in touch with you at their soonest.完成链接中的详细信息后,团队成员将尽快与您联系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM