image.png
In the process of using EC2, customers will inevitably encounter situations such as root volume corruption or operating system configuration errors, resulting in failure to connect and log in. This adds to the tedious work of day-to-day migrations, rebuilds, etc. Especially when customers use storage-optimized instances (such as i3, i3en, d2, etc.) and self-built services (such as Hadoop, Kafka), the cost of data loss and copying will be very high.

These expensive data replication operations on instance storage, complicated migration and reconstruction, etc. are often unaffordable to customers. Now relying on the Amazon ReplaceRootVolum e , it will help customers solve the above problems and easily cope with various challenges that arise.

Amazon ReplaceRootVolume

Introduction to new features

ReplaceRootVolume is a new feature that allows customers to replace the EBS root volume of an EC2 instance while preserving instance store data, networking and IAM configuration. Avoid losing, duplicating instance store data when an instance becomes inaccessible due to boot volume issues. The root volume can be restored to a previous snapshot while preserving instance store data.

ReplaceRootVolume function is very convenient and fast to use, no complicated operation is required, let's take a detailed look at how to configure and use this function on the d2 model (other models are the same operation).

Amazon ReplaceRootVolume

configure

At present, the latest version of Amazon Cli already supports commands related to ReplaceRootVolume operations, so the first step is to Amazon Cli to the latest version. For details, please refer to the official documentation:

https://docs.aws.amazon.com/zh_cn/cli/latest/userguide/install-cliv2.html

After the Amazon Cli upgrade is complete, you can start creating tasks using ReplaceRootVolume.

Create Recovery Task

The create-replace-root-volume-task command replaces an instance's EBS root volume with the last known good snapshot or boot state. Create-replace-root-volume-task Command input includes instance-id and snapshot-id . Instance-id is a required field, snapshot-id is optional. If no snapshot id is provided, the instance root volume will be restored to its startup state.

*If the root volume is snapshotted, keep at least one snapshot file as a recovery point.

The following command restores the root volume of instance i-055c4533f35830923 to its startup state.

aws ec2 create-replace-root-volume-task [--region instance location] [--instance-id <instance ID>]

The following command restores the root volume of instance i-055c4533f35830923 to the specified snapshot state.

aws ec2 create-replace-root-volume-task [--region instance region] [--instance-id <instance ID>] [-snapshot-id <snapshot ID> ]

After executing the restore task, you will see the following output:

image.png

Query task execution status:

After executing the above command, you can view the status of the current task with the following command:

aws ec2 describe-replace-root-volume-tasks –region “the region where the instance is located” –replace-root-volume-task-ids “TaskId in the output after the task is executed” –filters Name=instance-id,Values="Instance ID", "Instance ID"

You can see the execution of the task

image.png

Check the information before and after recovery to confirm that it is as expected

image.png

image.png

Work after recovery is complete

After the restoration is complete, you first need to check whether the restored version is the expected version.

Then remount the instance store to the corresponding mount point (if the restored system version has been configured for automatic mounting, you do not need to mount it manually).

Check that the data in the instance store is as expected.

image.png

Using the console to perform recovery tasks

The above describes that if you use the command line to perform the ReplaceRootVolume operation, this operation can also be conveniently performed on the console.

EC2 that needs to be executed in the console, in the storage information, find the replacement root volume.

image.png

After entering the replacement function page, select the snapshot ID to create a root volume recovery task.

image.png

In EC2 , you can see the status of the current task.

image.png

Through the ReplaceRootVolume , after simply replacing the root volume, you can efficiently, conveniently, and easily deal with the problems of inability to log in to the instance, the risk of instance storage data loss, and high migration costs.

The author of this article

Qiu

Amazon Cloud Technology Solution Architect

Responsible for consulting and design based on Amazon cloud technology solution architecture, and promoting Amazon cloud technology platform technology and solutions. Before joining Amazon Cloud Technology, he has worked for many years in the enterprise cloud, Internet entertainment, media and other industries, and has a deep understanding of public cloud business and architecture.

Wu Jinfu

Amazon Cloud Technology Hybrid Cloud Solution Architect

Responsible for consulting and design of hybrid cloud solution architecture based on Amazon cloud technology. Before joining Amazon Cloud Technology, he worked in a large group company. Responsible for the design and construction of private cloud data centers, and has many years of experience in data center infrastructure, virtualization, high-performance computing and hybrid cloud.


亚马逊云开发者
2.9k 声望9.6k 粉丝

亚马逊云开发者社区是面向开发者交流与互动的平台。在这里,你可以分享和获取有关云计算、人工智能、IoT、区块链等相关技术和前沿知识,也可以与同行或爱好者们交流探讨,共同成长。


引用和评论

0 条评论