文档概述:
RAID 0 又称为Stripe(条带化),将多个硬盘合并成一个大硬盘,不具有冗余,并行I/O。在存放数据时,将数据按磁盘个数进行分段,然后同时将这些数据写进磁盘中。在所有RAID级别中,RAID 0速度是最快的,为取得比通过单个卷取得的 I/O 性能更高的 I/O 性能,RAID 0 可将多个卷组合在一起。
AWS EBS卷同样也支持RAID 0的配置。本文将介绍AWS EBS卷RAID 0相关配置及实测磁盘吞吐量,仅供参考。
常见RAID配置选项:
比较常见的RAID配置如下表所示:
| 配置 | 使用 | 优点 | 缺点 |
| RAID0 | 当 I/O 性能比容错能力更重要时;例如在频繁使用的数据库中 (其中,已单独设置数据复制)。 | I/O 在卷内以条带状分布。如果您添加卷,则会直接增加吞吐量。 | I/O 在卷内以条带状分布。如果您添加卷,则会直接增加吞吐量。 |
| RAID1 | 当容错能力比 I/O 性能更重要时;例如在关键应用程序中。 | 在数据持久性方面更具安全性。 | 不提供写入性能改进;需要比非 RAID 配置更大的 Amazon EC2 到 Amazon EBS 带宽,因为数据将同时写入多个卷。 |
背景介绍:
一台AWS Linux EC2实例,根存储卷大小为默认8GB ,还挂载了4块未使用的EBS卷,分别为nvme3n1 33GB、nvme1n1 10GB、nvme2n1 10GB、nvme4n1 13GB。所有卷的IOPS大小均为100.
RAID0配置:
将其中3块盘创建RAID0条带化。
mdadm --create --verbose /dev/md0 --level=0 --name=RAID0 --raid-devices=3 /dev/nvme1n1 /dev/nvme2n1 /dev/nvme4n1
RAID0配置细节信息。mdadm --detail /dev/md0
创建文件系统。mkfs.ext4 -L RAID0 /dev/md0
创建挂载点,并挂载 mkdir -p /mnt/raid0 mount LABEL=RAID0 /mnt/raid0
增加/etc/fstab条目,设置开启自启动后执行mount –a 无报错即可。
为卷拍摄快照并测试数据完整性:
创建测试文件,生成一个1GB的文件,吞吐量为215MB/s
快照3块ebs卷,启动一台新ec2,将快照挂载
可看到自动创建raid元设备md127.创建目录挂载即可,数据也可以恢复
测试磁盘吞吐量:
| 吞吐量测试命令 | dd if=/dev/zero of=here bs=1G count=1 oflag=direct |
| RAID 0 20GB大小 (2块盘) | 吞吐量:205MB/s |
| 标准存储 根卷20GB(1块盘) | 吞吐量:141MB/s |
| 标准存储 根卷8GB(1块盘) | 吞吐量:145MB/s |
| RAID 0配置 33GB大小 (3块盘) | 吞吐量:215MB/s |
| 标准存储 33GB卷(1块盘) | 吞吐量:146MB/s |
实测结论:
- 对于33GB以下的标准EBS存储,IOPS 为100。最大吞吐量实测为140MB/s
- 对于将3个卷制作成RAID0方式(大小在33GB以下),吞吐量实测为210MB/s
- RAID0配置若坏一块盘,数据则会丢失,应定期拍摄快照
- RAID0适合于大规模并发读写,但对数据安全性要求不高场景中
Document Overview:
RAID 0, also known as Stripe, combines multiple hard drives into one large drive without redundancy, using parallel I/O. When storing data, data is segmented by the number of disks, then written to the disks simultaneously. Among all RAID levels, RAID 0 is the fastest. To achieve higher I/O performance than what can be obtained from a single volume, RAID 0 can combine multiple volumes together.
AWS EBS volumes also support RAID 0 configuration. This article will introduce AWS EBS volume RAID 0 related configuration and measured disk throughput, for reference only.
Common RAID Configuration Options:
The more common RAID configurations are shown in the table below:
| Configuration | Usage | Advantages | Disadvantages |
| RAID0 | When I/O performance is more important than fault tolerance; for example, in frequently used databases (where data replication is set up separately). | I/O is striped across volumes. If you add volumes, throughput increases directly. | I/O is striped across volumes. If you add volumes, throughput increases directly. |
| RAID1 | When fault tolerance is more important than I/O performance; for example, in critical applications. | More secure in terms of data durability. | Does not provide write performance improvement; requires more Amazon EC2 to Amazon EBS bandwidth than non-RAID configurations because data is written to multiple volumes simultaneously. |
Background:
An AWS Linux EC2 instance with a root storage volume size of default 8GB, also has 4 unused EBS volumes mounted: nvme3n1 33GB, nvme1n1 10GB, nvme2n1 10GB, nvme4n1 13GB. All volumes have IOPS of 100.
RAID0 Configuration:
Create RAID0 stripe using 3 of the disks.
mdadm --create --verbose /dev/md0 --level=0 --name=RAID0 --raid-devices=3 /dev/nvme1n1 /dev/nvme2n1 /dev/nvme4n1
RAID0 configuration details. mdadm --detail /dev/md0
Create file system. mkfs.ext4 -L RAID0 /dev/md0
Create mount point and mount: mkdir -p /mnt/raid0 mount LABEL=RAID0 /mnt/raid0
Add /etc/fstab entry, set auto-start on boot, then execute mount -a with no errors.
Create Snapshots for Volumes and Test Data Integrity:
Create test file, generate a 1GB file, throughput is 215MB/s
Snapshot 3 EBS volumes, start a new EC2, mount the snapshots
You can see the RAID meta device md127 is automatically created. Create directory and mount, data can be restored.
Test Disk Throughput:
| Throughput Test Command | dd if=/dev/zero of=here bs=1G count=1 oflag=direct |
| RAID 0 20GB size (2 disks) | Throughput: 205MB/s |
| Standard storage root volume 20GB (1 disk) | Throughput: 141MB/s |
| Standard storage root volume 8GB (1 disk) | Throughput: 145MB/s |
| RAID 0 configuration 33GB size (3 disks) | Throughput: 215MB/s |
| Standard storage 33GB volume (1 disk) | Throughput: 146MB/s |
Test Conclusions:
- For standard EBS storage under 33GB, IOPS is 100. Measured maximum throughput is 140MB/s
- For 3 volumes configured as RAID0 (size under 33GB), measured throughput is 210MB/s
- If one disk fails in RAID0 configuration, data will be lost; snapshots should be taken regularly
- RAID0 is suitable for large-scale concurrent read/write scenarios where data security requirements are not high