Tạo 1 EBS Volume > 16TB

Bài toán:

Muốn di chuyển từ on-prem (NAS) sang AWS (EBS), có khoảng 30TB data, và mong muốn tạo 1 EBS Volume có size là 30TB. EBS sẽ được mount trên EC2 (Windows server 2019), và muốn dùng type là st1

Mong muốn được chỉ cách để get snapshot và restore (bằng boto3)

Solution:

Rất tiếc là không có cách nào để tạo EBS Volume có volume type là HDD (st1) và dung lượng là 30TB.
Hiện tại chỉ có EBS volume type là IOPS SSD (io2) hỗ trợ lên đến 64 TB.

Tài liệu tham chiếu
 [1][Amazon EBS features]
 aws.amazon.com/ebs/features

Bạn có thể sử dụng chức năng “span volume” để tạo logic volume có dung lượng lớn hơn 16TB từ nhiều EBS Volume, tuy nhiên cách này không có tài liệu chính thức của AWS đề cập, và cũng sẽ gây ra một số khó khăn trong quá trình restore.

Ngoài ra, có cách làm khác là sử dụng striped volume (RAID 0) để tạo logic volume từ nhiều EBS Volume.

Chi tiết cách làm thì bạn hãy tham khảo [2] [3] nhé.

Bạn có thể tham khảo cách nữa là tạo logical volume tại đây: aws.amazon.com/premiumsupport/knowledge-cen..

Tài liệu tham chiếu
 [2][Volume Object]
 https://docs.microsoft.com/ja-jp/windows/win32/vds/volume-object
 —-

・A spanned volume combines areas of unallocated space from multiple disks into one logical volume, allowing you to more efficiently use all of the space and all the drive letters on a multiple-disk system.

・A striped volume is created by combining areas of free space on two or more disks into one logical volume. Striped volumes use RAID-0, which stripes data across multiple disks. Striped volumes cannot be extended or mirrored, and do not offer fault tolerance. If one of the disks containing a striped volume fails, the entire volume fails. When creating striped volumes, it is best to use disks that are of the same size, model, and manufacturer.
 —-

 [3][RAID configuration on Windows]
 https://docs.aws.amazon.com/ja_jp/AWSEC2/latest/WindowsGuide/raid-config.html#windows-raid

Để get snapshot và restore logic volume (spanned volume hoặc striped volume), bạn cần sử dụng tính năng EBS multi-volume snapshots của EBS. [4][5]

Tài liệu tham chiếu
 [4][RAID configuration on Windows]
https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/raid-config.html#ebs-snapshots-raid-array

 [5][Taking crash-consistent snapshots across multiple Amazon EBS volumes on an Amazon EC2 instance]
 aws.amazon.com/blogs/storage/taking-crash-c..

Ngoài ra, vì bạn đang dự định chuyển từ NAS lên AWS, bạn có thể cân nhắc phương án khác như là sử dụng Amazon FSx for Windows File Server để lưu trữ data nhé. [6][7]

Amazon FSx là fully managed service hỗ trợ SSD và HDD có capacity tối đa lên đến khoảng 562 TB (524288 GiB) [8]
Khi sử dụng Amazon FSx thì bạn dễ dàng backup và restore dữ liệu lưu trữ tại Amazon FSx, chi tiết tham khảo tài liệu [9]

Tài liệu tham chiếu:
 [6][What is FSx for Windows File Server?]
 https://docs.aws.amazon.com/ja_jp/fsx/latest/WindowsGuide/what-is.html

 [7][Use Amazon FSx with Amazon EC2]
 https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/storage_fsx.html

 [8] [Quotas]
 https://docs.aws.amazon.com/fsx/latest/WindowsGuide/limits.html#soft-limits

 [9][Working with backups]
 https://docs.aws.amazon.com/fsx/latest/WindowsGuide/using-backups.html

Để get multi-volume snapshot bằng AWS SDK for Python (Boto3), bạn sẽ sử dụng [create_snapshots].

Khi chỉ định InstanceSpecification, bạn không cần phải chỉ ra thứ tự các snapshot, mà chỉ cần chỉ định InstanceId của EC2 instance.

Mặc định, khi tạo muti-volume snapshots từ 1 EC2 instance, EBS sẽ tạo các snapshots của tất cả các volume được attached vào EC2 instance (bao gồm cả root và non-root volume)
Bạn có thể lựa chọn có tạo snapshot cho root volume hay không, hoặc không tạo snapshot cho 1 volume nào đó bằng cách chỉ định ID của volume muốn exclude trong ExcludeDataVolumeIds. [1]

Tài liệu tham chiếu:
 [1][EC2 | create_snapshots]
 boto3.amazonaws.com/v1/documentation/api/la..
 —
 Volumes are chosen by specifying an instance. Any attached volumes will produce one snapshot each that is crash-consistent across the instance. Boot volumes can be excluded by changing the parameters.
 —

Khi xóa, bạn sẽ cần thực hiện xóa cả 2 snapshots.

Sau khi thực hiện multi-volume snapshots, thì các hành động như delete, copy, hay restore sẽ được thực hiện tương tự như single volume snapshot [2]

Tài liệu tham chiếu:
 [2][Create Amazon EBS snapshots]
 https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ebs-creating-snapshot.html#ebs-create-snapshot-multi-volume
 —
 After the snapshots are created, each snapshot is treated as an individual snapshot. You can perform all snapshot operations, such as restore, delete, and copy across Regions or accounts, just as you would with a single volume snapshot.
 —

\=> Câu hỏi: Nếu sử dụng span volume để tạo ra:

Dù có restore từ multi-volume snapshot thì Windows cũng có hiểu là span volume không?

Trả lời:

Tôi đã thực hiện kiểm chứng, và kết quả là:
Các vùng volume span vẫn sẽ được tự động phát hiện khi detach EBS volume khỏi EC2 instance rồi attach EBS volume đã restore vào EC2 instance, các file được lưu trữ tại vùng spanned vẫn có thể sử dụng bình thường (xem ảnh phía dưới).

Lưu ý rằng: Sau khi attach EBS volume đã restore vào EC2 instance, các disk vùng span volume sẽ bị offline (136205-offline-when-attach.png). Bạn sẽ cần phải login vào EC2 instance và set Online cho volume. Chi tiết cách làm:
・ Step 1: In the search box on the taskbar, type Disk Management, select and hold (or right-click) Disk Management, then select Run as administrator > Yes. If you can’t open it as an administrator, type Computer Management instead, and then go to Storage > Disk Management.
・ Step 2: In Disk Management, if the disk is listed as Offline, first right-click it and select Online.

Tài liệu tham khảo:

https://docs.microsoft.com/en-us/windows-server/storage/disk-management/initialize-new-disks

Ngoài ra thì, với span volume, nếu bạn attach sang 1 instance khác, thì sẽ không đảm bảo Windows nhận ra đó là vùng span.

Lưu ý rằng:
・ Bạn sẽ phải stop EC2 instance mới có thể detach vùng system (root volume).
・ Sau khi attach root volume và khởi động lại EC2 instance, bạn cũng sẽ phải thực hiện online data volume

Volume offline khi attach:

Sau khi online đã dùng bình thường:

Bạn có thể sử dụng get multi volume snapshot bằng [create_snapshots] để get single volume snapshot mà không có vấn đề gì cả.

Ngoài ra, vì create_snapshots() là function mới nên khi phát triển và deploy source code python để get snapshot, bạn hãy đảm bảo sử dụng AWS SDK for Python (boto3) mới nhất nhé.
Ở thời điểm 2022/09/12 thì version mới nhất của boto3 là 1.24.70 [1]

Tài liệu tham chiếu
 [1] [boto/boto3 | Tags]
 github.com/boto/boto3/tags

Trường hợp khách hàng sử dụng AWS Service như là Lambda (runtime là Python) để get snapshot thì boto3 version có trong Runtime không phải lúc nào cũng bao gồm SDK mới nhất nên có thể phát sinh lỗi như chưa implement, lỗi SDK v.v..
Vì vậy trong trường hợp phát sinh lỗi, khách hàng hãy cần phải update AWS SDK, chi tiết bạn hãy xác nhận nội dung trả lời dưới đây từ AWS nhé

\========
AWS cập nhật định kỳ cho SDK Version có trong Runtime nhưng vì không phải lúc nào cũng bao gồm SDK mới nhất nên
nếu chạy các chức năng của dịch vụ AWS 1 cách tương đối giống như create_snapshots() lần này, có thể phát sinh lỗi giống như case này do các nguyên nhân như chưa implement, lỗi SDK v.v .
Với các trường hợp kiểu này, khách hàng cần phải update AWS SDK mới nhất cho môi trường của Lambda Function và sử dụng.
Ngoài ra tôi xác nhận trên môi trường của tôi với AWS SDK for Python(boto3 1.24.70) mới nhất, khi chạy code giống khách hàng thi đã hoàn thành mà không có lỗi gì.

Như là 1 phương pháp mà khách hàng sẽ sử dụng tùy ý module của version bằng Lambda_function: có chức năng deploy package và layer
Sử dụng những chức năng này và thiết định môi trường có thể sử dụng AWS SDK for Python mới nhất, rồi hãy chạy code của khách nhé.

Tham khảo
[Deploy Python Lambda functions with .zip file archives]
docs.aws.amazon.com/lambda/latest/dg/python..

[Creating and sharing Lambda layers]
https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html#configuration-layers-create

\========