Red Hat Training

A Red Hat training course is available for RHEL 8

9.23. 重塑 RAID 卷

RAID 重塑意味着在不更改 RAID 级别的情况下更改 RAID 逻辑卷的属性。您可以更改的一些属性包括 RAID 布局、条带大小和条带数目。

流程

  1. 创建 RAID 逻辑卷:

    # lvcreate --type raid5 -i 2 -L 500M -n my_lv my_vg
    
    Using default stripesize 64.00 KiB.
    Rounding size 500.00 MiB (125 extents) up to stripe boundary size 504.00 MiB (126 extents).
    Logical volume "my_lv" created.
  2. 查看 RAID 逻辑卷:

    # lvs -a -o +devices
    
    LV               VG    Attr       LSize   Pool   Origin Data% Meta% Move Log Cpy%Sync Convert Devices
    my_lv            my_vg rwi-a-r--- 504.00m                                    100.00            my_lv_rimage_0(0),my_lv_rimage_1(0),my_lv_rimage_2(0)
    [my_lv_rimage_0] my_vg iwi-aor--- 252.00m                                                      /dev/sda(1)
    [my_lv_rimage_1] my_vg iwi-aor--- 252.00m                                                      /dev/sdb(1)
    [my_lv_rimage_2] my_vg iwi-aor--- 252.00m                                                      /dev/sdc(1)
    [my_lv_rmeta_0]  my_vg ewi-aor---   4.00m                                                      /dev/sda(0)
    [my_lv_rmeta_1]  my_vg ewi-aor---   4.00m                                                      /dev/sdb(0)
    [my_lv_rmeta_2]  my_vg ewi-aor---   4.00m                                                      /dev/sdc(0)
  3. 可选:查看 RAID 逻辑卷的 stripes 镜像和 stripesize

    # lvs -o stripes my_vg/my_lv
      #Str
         3
    # lvs -o stripesize my_vg/my_lv
      Stripe
      64.00k
  4. 根据您的要求,使用以下方法修改 RAID 逻辑卷的属性:

    1. 修改 RAID 逻辑卷的 stripes 镜像:

      # lvconvert --stripes 3 my_vg/my_lv
      Using default stripesize 64.00 KiB.
      WARNING: Adding stripes to active logical volume my_vg/my_lv will grow it from 126 to 189 extents!
      Run "lvresize -l126 my_vg/my_lv" to shrink it or use the additional capacity.
      Are you sure you want to add 1 images to raid5 LV my_vg/my_lv? [y/n]: y
      Logical volume my_vg/my_lv successfully converted.
    2. 修改 RAID 逻辑卷的 stripesize

      # lvconvert --stripesize 128k my_vg/my_lv
        Converting stripesize 64.00 KiB of raid5 LV my_vg/my_lv to 128.00 KiB.
      Are you sure you want to convert raid5 LV my_vg/my_lv? [y/n]: y
        Logical volume my_vg/my_lv successfully converted.
    3. 修改 maxrecoveryrateminrecoveryrate 属性:

      # lvchange --maxrecoveryrate 4M my_vg/my_lv
        Logical volume my_vg/my_lv changed.
      # lvchange --minrecoveryrate 1M my_vg/my_lv
        Logical volume my_vg/my_lv changed.
    4. 修改 syncaction 属性:

      # lvchange --syncaction check my_vg/my_lv
    5. 修改 writemostlywritebehind 属性:

      # lvchange --writemostly /dev/sdb my_vg/my_lv
        Logical volume my_vg/my_lv changed.
      # lvchange --writebehind 100 my_vg/my_lv
        Logical volume my_vg/my_lv changed.

验证

  1. 查看 RAID 逻辑卷的 stripes 镜像和 stripesize

    # lvs -o stripes my_vg/my_lv
      #Str
         4
    # lvs -o stripesize my_vg/my_lv
      Stripe
      128.00k
  2. 修改 maxrecoveryrate 属性后,查看 RAID 逻辑卷:

    # lvs -a -o +raid_max_recovery_rate
      LV               VG       Attr        LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert MaxSync
      my_lv            my_vg    rwi-a-r---  10.00g                                     100.00           4096
      [my_lv_rimage_0] my_vg    iwi-aor---  10.00g
     [...]
  3. 修改 minrecoveryrate 属性后,查看 RAID 逻辑卷:

    # lvs -a -o +raid_min_recovery_rate
      LV               VG     Attr        LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert MinSync
      my_lv            my_vg  rwi-a-r---  10.00g                                     100.00           1024
      [my_lv_rimage_0] my_vg  iwi-aor---  10.00g
      [...]
  4. 修改 syncaction 属性后,查看 RAID 逻辑卷:

    # lvs -a
      LV               VG      Attr        LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
      my_lv            my_vg   rwi-a-r---  10.00g                                     2.66
      [my_lv_rimage_0] my_vg   iwi-aor---  10.00g
      [...]

其他资源

  • lvconvert (8)lvmraid (8) 手册页