理解linux下的软阵列和lvm
2014-09-16 17:36:51 阿炯

单纯地从技术上讲,RAID(软件实现)与LVM并没有必然的联系,它们的共同点是,都是linux磁盘管理工具之一,将多块磁盘组合利用;不同的是,软阵列可提供数据安全和性能提升,而lvm提供灵活的分区大小。可以把两者结合起来使用,就可以得到数据安全性及磁盘的灵活使用。

下列图示演示了两者间的组织关系

| / | /var | /usr | /home  |
 --------------------------
|       LVM Volume         |
 --------------------------
|       RAID Volume        |
 --------------------------
| Disk 1 | Disk 2 | Disk 3 |


| / | /var | /usr | /home  |
 --------------------------
|       LVM Volume 2       |
 --------------------------
|    RAID 0   |   Raid 1   |
 --------------------------
|       LVM Volume 1       |
 --------------------------
| Disk 1 | Disk 2 | Disk 3 |

It's a much simpler setup with more flexibility. You can use all of the disks in the RAID volume and slice and dice them whatever way you like with LVM. The other way isn't even worth thinking about - it's ridiculously complicated and you lose the benefits of LVM at the filesystem level.

这是一个简单的设置可得到更大的灵活性,您可以使用所有磁盘的RAID卷切片和分块与LVM配合,这样您喜欢的任何方式来分区。其他方式甚至不值得考虑——这种复杂和你失去了在文件系统级别分区的好处。

If you tried to RAID LVM volumes, you would be left with a normal device without any of the LVM volume benefits (e.g. growing filesystems etc.)

如果你试图使用基于RAID的LVM卷,你会留下一个的正常设备,这样用不到LVM卷的任何好处(如不断增长的文件系统等等)。

Raid deals with keeping the bits secure/redundant/fast/whatever and LVM helps you present them in a esasy to use way.

Raid处理保持位安全/冗余/快速,LVM帮助你使用容易。

They can seem comparable at first sight, because LVM lets you use several drives as one, and RAID is all about joining drives; but they're totally different in fact.

他们看起来是可比的,因为LVM允许您使用几个驱动器作为一个来使用,和RAID是加入驱动器,但事实上他们是完全不同的。

RAID is used to join several drives as a single volume. Different RAID schemes let you increase capacity, speed, reliability, or all. In the end, you get with something that is just like one bigger, faster, better drive.

RAID是用来联接多个驱动器作为单个卷。不同的RAID级别让你增加容量、速度、可靠性、或全部特性。最后你将得到的磁盘,一个更大、更快、更好的驱动器。

LVM is a very flexible volume manager. Although it has a couple of RAID modules, if you want RAID's redundancy or speed, put LVM on top of a RAID (or several). The purpose of LVM is joining several volumes (can be drives or RAIDs or a mix) into a 'Volume Group'. Then, you create new 'Logical Volumes' from the group. That gives you a lot of flexibility because you can later reassign capacity between the Logical Volumes, and add or remove Physical Volumes from the Volume Group. It really lets you think in a different way about storage.

LVM是一个非常灵活的卷管理器。尽管它有一个RAID模块,如果你想要得到冗余或速度,将LVM建立在RAID上。LVM的目的是加入几个卷(可以是驱动器混合)成一个卷组,然后您创建的新逻辑卷的组。这样可以有很大的灵活性,因为您可以稍后再分配逻辑卷,添加或删除物理卷的卷组。它可以让你以不同的方式来规划存储。

典型用例:

a workstation can sometimes benefit from LVM if you want to have a "better partition than partitions"; but usually a single partition is enough and easier to handle. Also RAID1 (mirroring) is nice because the extra speed and stability, especially now that storage is so cheap.

工作站有时可以受益于LVM,如果你想有一个“灵活的分区”方案,但通常单个分区就足够了,而且更容易操作。还是RAID1(镜像)比较好的,因为额外的速度和稳定性,而且现在存储是如此便宜。

a file server can use LVM to grow at any time, and usually the physical volumes you add to the volume group are RAIDs, so you can get extra reliability and uptime. Also, you can assign and reassign storage to different sharepoints.

文件服务器可以使用LVM,这样在任何时候可自由调整,而且通常的物理卷轻松地添加到卷组中,所以你可以得到额外的可靠性和正常运行时间。同样,你可以再分配存储到不同的sharepoint。

a DB server needs the ultimate in seek time, neither RAID nor LVM help here (besides a little higher concurrency with RAID1). Usually DBs use a simple RAID1 of very fast (and low capacity) SAS drives (10-15krpm), at least for the indexes. sometimes you put the data on slower (and cheaper) disks, on RAID1,5 or 6.

数据库服务器需要最终寻道时间最少,RAID和LVM在这里的作用有限(RAID1 除了有点更高的并发性)。通常数据库使用一个简单的RAID1的非常快(和低容量)SAS驱动器(10-15krpm),至少在索引上。有时你把数据放在较慢(便宜)磁盘,RAID1,5或6。

They are different things. With RAID you try to get redundancy (usually) out of disks. With LVM you allocate disk space flexibly. If you want redundancy, use RAID. If you want flexibility, use LVM. If both, use LVM over RAID. Sometimes RAID capability is part of LVM. In many situations you need flexibility and therefore LVM.

他们是不同的磁盘组织方式,RAID可让磁盘冗余。与LVM配合可让磁盘空间分配更灵活。如果你想要冗余,可使用RAID,如果你想要的灵活性,使用LVM。有时RAID功能是LVM的一部分,在很多情况下你需要的灵活性,因此使用LVM。

你可以从维基百科了解这两种方式定义说明:
LVM:http://en.wikipedia.org/wiki/Logical_volume_management
RAID:http://en.wikipedia.org/wiki/RAID


Linux中建立软raid

本节参照了苦逼运维的文章,感谢原作者。

Linux内核中有一个md(multiple devices)模块在内核层管理RAID设备,在用户态会提供一个应用程序的工具mdadm,它用于构建、管理和监视Linux MD设备(即RAID阵列)。

(1).mdadm的常用选项

-C,--create 新建一个阵列
-r,--remove 删除列出的设备,设备不可处于活动状态
-A,--assemble 激活阵列
-l,--level== 设置阵列级别
-D,--detail 打印一个或多个阵列设备信息
-n,--raid-devices= 指定阵列成员信息
-s,-scan 扫描配置文件或/proc/mdstat得到阵列缺失信息
-x或--spare-devices= 指定阵列中备用盘的数量
-f,--fail 将列出的设备标记为故障
-c,--chunk= 指定阵列的块大小。默认512K
-a,--add 添加设备到阵列
-G,--grow改变阵列大小和形态
-v,--verbose 显示详细信息
-S,--stop 停止阵列,释放所有资源

(2).实例

实验环境:CentOS7
raid类型     磁盘或分区     热备盘
raid0     sdb、sdc     
raid1     sdd、sde     sdf
raid5     sdg、sdh、sdi     sdj
raid10     sdk1、sdk2、sdk3、sdk4     

1)创建raid0

# ls /dev/sd*
/dev/sda   /dev/sda2  /dev/sdb  /dev/sdd  /dev/sdf  /dev/sdh  /dev/sdj
/dev/sda1  /dev/sda3  /dev/sdc  /dev/sde  /dev/sdg  /dev/sdi  /dev/sdk

# mdadm -v -C /dev/md0 -l 0 -n 2 /dev/sdb /dev/sdc
mdadm: chunk size defaults to 512K
mdadm: partition table exists on /dev/sdb
mdadm: partition table exists on /dev/sdb but will be lost or
       meaningless after creating array
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

# mdadm -D  //提示没有给出设备
mdadm: No devices given.

# mdadm -Ds  //指定从配置文件或内存文件(/proc/mdadm)中读取
ARRAY /dev/md0 metadata=1.2 name=freeoa:0 UUID=d1143d41:be8e61b8:d368f0a1:8df95826

# mdadm -Dsv  //显示更详细一些
ARRAY /dev/md0 level=raid0 num-devices=2 metadata=1.2 name=freeoa:0 UUID=d1143d41:be8e61b8:d368f0a1:8df95826
   devices=/dev/sdb,/dev/sdc

# mdadm -D /dev/md0  //也可以直接指定设备
/dev/md0:
           Version : 1.2
     Creation Time : Sun Mar 17 21:51:29 2019
        Raid Level : raid0  //raid级别
        Array Size : 41908224 (39.97 GiB 42.91 GB)  //GiB是用1024计算,GB是用1000计算
      Raid Devices : 2  //raid盘
     Total Devices : 2  //总共拥有的盘(raid盘+热备盘)
       Persistence : Superblock is persistent
 
       Update Time : Sun Mar 17 21:51:29 2019
             State : clean
    Active Devices : 2
   Working Devices : 2
    Failed Devices : 0
     Spare Devices : 0
 
        Chunk Size : 512K  //chunk块大小
 
Consistency Policy : none
 
              Name : freeoa:0  (local to host freeoa)
              UUID : d1143d41:be8e61b8:d368f0a1:8df95826
            Events : 0
 
    Number   Major   Minor   RaidDevice State
       0       8       16        0      active sync   /dev/sdb  //组成的设备信息
       1       8       32        1      active sync   /dev/sdc  //组成的设备信息
# mdadm -Dsv > /etc/mdadm.conf  //生成配置文件,配置文件名固定。

raid的格式化和挂载和正常的设备没有什么区别,当成正常的设备即可,如下:
# mkfs.xfs /dev/md0
meta-data=/dev/md0               isize=512    agcount=16, agsize=654720 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=10475520, imaxpct=25
         =                       sunit=128    swidth=256 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=5120, version=2
         =                       sectsz=512   sunit=8 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

# mkdir /raid0
# mount /dev/md0 /raid0/
# df -h /dev/md0
文件系统        容量  已用  可用 已用% 挂载点
/dev/md0         40G   33M   40G    1% /raid0

开机自动挂载也是如正常设备一样(blkid /dev/md0可以获得UUID)。

2)创建raid1

# mdadm -v -C /dev/md1 -l 1 -n 2 -x 1 /dev/sd[d,e,f]
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata,
    or use --metadata=0.90
mdadm: size set to 20954112K
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md1 started.
# mdadm -Dsv
ARRAY /dev/md0 level=raid0 num-devices=2 metadata=1.2 name=freeoa:0 UUID=d1143d41:be8e61b8:d368f0a1:8df95826
   devices=/dev/sdb,/dev/sdc
ARRAY /dev/md1 level=raid1 num-devices=2 metadata=1.2 spares=1 name=freeoa:1 UUID=4b922235:5a26daf2:2eed2067:959a76ee
   devices=/dev/sdd,/dev/sde,/dev/sdf

# mdadm -Dsv > /etc/mdadm.conf   //生成配置文件

# mdadm -D /dev/md1
/dev/md1:
           Version : 1.2
     Creation Time : Sun Mar 17 22:13:13 2019
        Raid Level : raid1  //raid级别
        Array Size : 20954112 (19.98 GiB 21.46 GB)
     Used Dev Size : 20954112 (19.98 GiB 21.46 GB)
      Raid Devices : 2  //raid盘
     Total Devices : 3  //总共拥有的盘
       Persistence : Superblock is persistent
 
       Update Time : Sun Mar 17 22:13:40 2019
             State : clean
    Active Devices : 2
   Working Devices : 3
    Failed Devices : 0
     Spare Devices : 1
 
Consistency Policy : resync  //如果此处显示百分比,则代表正在同步
              Name : freeoa:1  (local to host freeoa)
              UUID : 4b922235:5a26daf2:2eed2067:959a76ee
            Events : 17
 
    Number   Major   Minor   RaidDevice State
       0       8       48        0      active sync   /dev/sdd
       1       8       64        1      active sync   /dev/sde
 
       2       8       80        -      spare   /dev/sdf

  模拟磁盘故障,自动顶替故障盘

# mkfs.xfs /dev/md1  //格式化
meta-data=/dev/md1               isize=512    agcount=4, agsize=1309632 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=5238528, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

# mkdir /raid1

# mount /dev/md1 /raid1  //挂载

# cp /etc/passwd /raid1/  //拷贝数据

# cp -r /boot/grub /raid1/

# df -h /dev/md1
文件系统        容量  已用  可用 已用% 挂载点
/dev/md1         20G   33M   20G    1% /raid1
# mdadm -D /dev/md1
/dev/md1:
           Version : 1.2
     Creation Time : Sun Mar 17 22:13:13 2019
        Raid Level : raid1
        Array Size : 20954112 (19.98 GiB 21.46 GB)
     Used Dev Size : 20954112 (19.98 GiB 21.46 GB)
      Raid Devices : 2
     Total Devices : 3
       Persistence : Superblock is persistent
 
       Update Time : Sun Mar 17 22:31:04 2019
             State : clean
    Active Devices : 2
   Working Devices : 3
    Failed Devices : 0
     Spare Devices : 1

Consistency Policy : resync

              Name : freeoa:1  (local to host freeoa)
              UUID : 4b922235:5a26daf2:2eed2067:959a76ee
            Events : 17

    Number   Major   Minor   RaidDevice State
       0       8       48        0      active sync   /dev/sdd
       1       8       64        1      active sync   /dev/sde
       2       8       80        -      spare   /dev/sdf

# mdadm /dev/md1 -f /dev/sde  //将/dev/sde标记为坏盘
mdadm: set /dev/sde faulty in /dev/md1

# mdadm -D /dev/md1
/dev/md1:
           Version : 1.2
     Creation Time : Sun Mar 17 22:13:13 2019
        Raid Level : raid1
        Array Size : 20954112 (19.98 GiB 21.46 GB)
     Used Dev Size : 20954112 (19.98 GiB 21.46 GB)
      Raid Devices : 2
     Total Devices : 3
       Persistence : Superblock is persistent

       Update Time : Sun Mar 17 22:33:36 2019
             State : clean, degraded, recovering
    Active Devices : 1
   Working Devices : 2
    Failed Devices : 1
     Spare Devices : 1

Consistency Policy : resync

    Rebuild Status : 71% complete  //正在同步
              Name : freeoa:1  (local to host freeoa)
              UUID : 4b922235:5a26daf2:2eed2067:959a76ee
            Events : 30

    Number   Major   Minor   RaidDevice State
       0       8       48        0      active sync   /dev/sdd
       2       8       80        1      spare rebuilding   /dev/sdf  //热备盘正在重建
       1       8       64        -      faulty   /dev/sde  //损坏标记
# mdadm -Dsv > /etc/mdadm.conf  //更新配置文件

移除损坏的盘
# umount /raid1/  //卸载挂载
# mdadm -r /dev/md1 /dev/sde  //移除坏盘
mdadm: hot removed /dev/sde from /dev/md1

添加新盘
# mdadm -a /dev/md1 /dev/sde  //添加新盘
mdadm: added /dev/sde
# mdadm -Dsv > /etc/mdadm.conf   //更新配置文件

3)创建raid5

# mdadm -v -C /dev/md5 -l 5 -n 3 -x 1 -c32 /dev/sd{g,h,i,j}
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: size set to 20954112K
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md5 started.

# mdadm -D /dev/md5
/dev/md5:
           Version : 1.2
     Creation Time : Sun Mar 17 22:51:42 2019
        Raid Level : raid5  //raid级别
        Array Size : 41908224 (39.97 GiB 42.91 GB)
     Used Dev Size : 20954112 (19.98 GiB 21.46 GB)
      Raid Devices : 3
     Total Devices : 4
       Persistence : Superblock is persistent

       Update Time : Sun Mar 17 22:52:01 2019
             State : clean, degraded, recovering
    Active Devices : 2
   Working Devices : 4
    Failed Devices : 0
     Spare Devices : 2

            Layout : left-symmetric
        Chunk Size : 32K  //chunk块大小

Consistency Policy : resync

    Rebuild Status : 32% complete  //正在同步

              Name : freeoa:5  (local to host freeoa)
              UUID : fa44697c:20726a38:fcf7c1d5:f584b82f
            Events : 6

    Number   Major   Minor   RaidDevice State
       0       8       96        0      active sync   /dev/sdg
       1       8      112        1      active sync   /dev/sdh
       4       8      128        2      spare rebuilding   /dev/sdi

       3       8      144        -      spare   /dev/sdj  //热备盘
# mdadm -Dsv > /etc/mdadm.conf   //更新配置文件

停止阵列,注意请确认数据已同步完成
# mdadm -S /dev/md5
mdadm: stopped /dev/md5

激活阵列,注意配置文件内必须存在
# mdadm -As
mdadm: /dev/md5 has been started with 3 drives and 1 spare.

扩展raid5自盘阵列
# mdadm -G /dev/md5 -n 4 -c 32  //将热备盘扩展进raid5

# mdadm -D /dev/md5
/dev/md5:
           Version : 1.2
     Creation Time : Sun Mar 17 22:51:42 2019
        Raid Level : raid5
        Array Size : 41908224 (39.97 GiB 42.91 GB)  //如果没有同不好,raid阵列大小会暂时不变
     Used Dev Size : 20954112 (19.98 GiB 21.46 GB)
      Raid Devices : 4
     Total Devices : 4
       Persistence : Superblock is persistent

       Update Time : Sun Mar 17 23:02:11 2019
             State : clean, reshaping
    Active Devices : 4
   Working Devices : 4
    Failed Devices : 0
     Spare Devices : 0
            Layout : left-symmetric
        Chunk Size : 32K

Consistency Policy : resync

    Reshape Status : 17% complete  //正在同步
     Delta Devices : 1, (3->4)  //扩展中

              Name : freeoa:5  (local to host freeoa)
              UUID : fa44697c:20726a38:fcf7c1d5:f584b82f
            Events : 48

    Number   Major   Minor   RaidDevice State
       0       8       96        0      active sync   /dev/sdg
       1       8      112        1      active sync   /dev/sdh
       4       8      128        2      active sync   /dev/sdi
       3       8      144        3      active sync   /dev/sdj
# mdadm -Dsv > /etc/mdadm.conf   //更新配置文件

注意:raid5只能增加不能减少,raid1可增加可减少。(少于两块盘,那就不叫raid1了啊)

4)创建raid10

# fdisk /dev/sdk  //创建4个分区
欢迎使用 fdisk (util-linux 2.23.2)。

更改将停留在内存中,直到您决定将更改写入磁盘。使用写入命令前请三思。

Device does not contain a recognized partition table
使用磁盘标识符 0x4b57a9c6 创建新的 DOS 磁盘标签。

命令(输入 m 获取帮助):n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
分区号 (1-4,默认 1):
起始 扇区 (2048-41943039,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-41943039,默认为 41943039):+1G
分区 1 已设置为 Linux 类型,大小设为 1 GiB

命令(输入 m 获取帮助):n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
分区号 (2-4,默认 2):
起始 扇区 (2099200-41943039,默认为 2099200):
将使用默认值 2099200
Last 扇区, +扇区 or +size{K,M,G} (2099200-41943039,默认为 41943039):+1G
分区 2 已设置为 Linux 类型,大小设为 1 GiB

命令(输入 m 获取帮助):n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
分区号 (3,4,默认 3):
起始 扇区 (4196352-41943039,默认为 4196352):
将使用默认值 4196352
Last 扇区, +扇区 or +size{K,M,G} (4196352-41943039,默认为 41943039):+1G
分区 3 已设置为 Linux 类型,大小设为 1 GiB

命令(输入 m 获取帮助):n
Partition type:
   p   primary (3 primary, 0 extended, 1 free)
   e   extended
Select (default e): p
已选择分区 4
起始 扇区 (6293504-41943039,默认为 6293504):
将使用默认值 6293504
Last 扇区, +扇区 or +size{K,M,G} (6293504-41943039,默认为 41943039):+1G
分区 4 已设置为 Linux 类型,大小设为 1 GiB

命令(输入 m 获取帮助):w
The partition table has been altered!

Calling ioctl() to re-read partition table.
正在同步磁盘。

# ls /dev/sdk*
/dev/sdk  /dev/sdk1  /dev/sdk2  /dev/sdk3  /dev/sdk4

# mdadm -v -C /dev/md10 -l 10 -n 4 /dev/sdk[1-4]
mdadm: layout defaults to n2
mdadm: layout defaults to n2
mdadm: chunk size defaults to 512K
mdadm: size set to 1046528K
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md10 started.

# mdadm -Dsv > /etc/mdadm.conf   //更新配置文件

5)删除raid的所有信息及注意事项

# df -h /raid*
文件系统        容量  已用  可用 已用% 挂载点
/dev/md0         40G   33M   40G    1% /raid0
/dev/sda2        10G  4.7G  5.4G   47% /

# umount /raid0/  //卸载挂载

# mdadm -Ss  //停止raid设备

# rm -rf /etc/mdadm.conf   //删除配置文件

# mdadm --zero-superblock /dev/sdb   //擦除设备中的raid标识(超级块)

# mdadm --zero-superblock /dev/sdc


6)相关调优

区块设备控制调节文件预读大小
blockdev --setra 4096 /dev/md0
blockdev --setra 4096 /dev/myvg/mylv

如果主机内存充裕,可以使用部分内存用作缓冲区来提高I/O效率
echo 8192 > /sys/block/md0/md/stripe_cache_size


Lvm是否已经支持了Raid功能?


2022年2月,在Devuan4下用LVM方式来将三个相同大小的独立分区使用stripes方式组建卷组后,再划分分区使用xfs文件系统挂载。发现该挂载点下只有一个文件,但从df与du查看时大小却不一样。。。

hto@freeoa:~$ df -hT
文件系统               类型      容量  已用  可用 已用% 挂载点
...
/dev/mapper/vgm-lvdata xfs       4.0T   58G  4.0T    2% /home/svm

hto@freeoa:~$ ls -lh /home/svm/
总用量 29G
-rwxrwxrwx 1 hto hto 29G 12月 29 10:42 simp.billion.log

这种结论非常娄似于3块盘的Raid5的算法。。

root@freeoa:~# vgdisplay vgm
--- Volume group ---
VG Name               vgm
System ID             
Format                lvm2
Metadata Areas        3
Metadata Sequence No  2
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                1
Open LV               1
Max PV                0
Cur PV                3
Act PV                3
VG Size               <5.46 TiB
PE Size               4.00 MiB
Total PE              1431072
Alloc PE / Size       1048578 / 4.00 TiB
Free  PE / Size       382494 / <1.46 TiB
VG UUID               ...

root@freeoa:~# lvdisplay -v /dev/vgm/lvdata
--- Logical volume ---
LV Path                /dev/vgm/lvdata
LV Name                lvdata
VG Name                vgm
LV UUID                ...
LV Write Access        read/write
LV Creation host, time freeoa, 2022-01-20 13:07:51 +0800
LV Status              available
# open                 1
LV Size                4.00 TiB
Current LE             1048578
Segments               1
Allocation             inherit
Read ahead sectors     auto
- currently set to     768
Block device           253:0

查看支持哪些算法

root@freeoa:~# lvm segtypes
linear
striped
zero
error
snapshot
mirror
raid0
raid0_meta
raid1
raid10
raid10_near
raid4
raid5
raid5_n
raid5_la
raid5_ls
raid5_ra
raid5_rs
raid6
raid6_n_6
raid6_nc
raid6_nr
raid6_zr
raid6_ls_6
raid6_rs_6
raid6_la_6
raid6_ra_6
thin-pool
thin
cache-pool
cache
vdo
vdo-pool
writecache
integrity

看来比传统的硬件阵列和Linux下的软阵列支撑的还有丰富。

接下来对分区进行组建和格式化操作。

RAID 0
vgcreate [vg name] /dev/sd[x]1 /dev/sd[x2]1 ...
lvcreate -i[num drives] -I[strip size] -l100%FREE -n[lv name] [vg name]
mkfs.[ext4/xfs] /dev/[vg name]/[lv name]

RAID 1
vgcreate vg1 /dev/sd[x]1 /dev/sd[x]1
lvcreate --mirrors 1 --type raid1 -l 100%FREE --nosync -n lvm_raid1 vg1

RAID 5
vgcreate vg1 /dev/sd[x]1 /dev/sd[x]1 /dev/sd[x]1
lvcreate --type raid5 -l 100%FREE --nosync -n lvm_raid5 vg1

参数说明:
-n – to assign a name to the volume.
--type raid5 – to set the array type.
-L – to set a size limit for the logical volume (in our example, its size is 10 GB).
-i – to indicate the number of devices involved to store user data. It doesn’t include an additional device to store parity blocks, though. The number you give should be 2 or more, because the minimum requirement for this array type is three disks.
vg1 – to tell the operating system where to take the required disk space from (specify a particular volume or an entire group).

After the command is performed successfully, the process of rebuilding a RAID 5 system in an LVM virtual group is over. The last step is to format the array and mount it.

LVM RAID Status(状态查询)

lvs -a -o name,copy_percent,devices vgm


参考链接
lvmraid(7)
《RHEL配置和管理逻辑卷》第 10 章 配置 RAID 逻辑卷