CentOS 8
Sponsored Link

LVM : Configure Mirroring Volume2020/02/07

 
Configure Mirroring Volumes. It is like RAID 1.
[1] For example, create a Mirroring Volume with Phisical Volume [/dev/sdb1] and [/dev/sdc1].
# create vlume group [vg_mirror] with [/dev/sdb1] and [/dev/sdc1]

[root@dlp ~]#
vgcreate vg_mirror /dev/sdb1 /dev/sdc1

  Volume group "vg_mirror" successfully created

# create a mirroring volume

[root@dlp ~]#
lvcreate -L 50G -m1 -n lv_mirror vg_mirror

[ 2531.959241] raid6: sse2x1   gen() 10359 MB/s
[ 2531.976238] raid6: sse2x1   xor()  7939 MB/s
[ 2531.993235] raid6: sse2x2   gen() 13230 MB/s
[ 2532.010231] raid6: sse2x2   xor()  8603 MB/s
[ 2532.027235] raid6: sse2x4   gen() 16101 MB/s
[ 2532.044231] raid6: sse2x4   xor()  9671 MB/s
[ 2532.061232] raid6: avx2x1   gen() 22093 MB/s
[ 2532.078231] raid6: avx2x1   xor() 15058 MB/s
[ 2532.095212] raid6: avx2x2   gen() 25875 MB/s
[ 2532.112225] raid6: avx2x2   xor() 15529 MB/s
[ 2532.129227] raid6: avx2x4   gen() 28554 MB/s
[ 2532.146226] raid6: avx2x4   xor() 16769 MB/s
[ 2532.146888] raid6: using algorithm avx2x4 gen() 28554 MB/s
[ 2532.147712] raid6: .... xor() 16769 MB/s, rmw enabled
[ 2532.148476] raid6: using avx2x2 recovery algorithm
[ 2532.150492] async_tx: api initialized (async)
[ 2532.152735] xor: automatically using best checksumming function   avx
[ 2532.172850] device-mapper: raid: Loading target version 1.14.0
[ 2543.906914] device-mapper: raid: Superblocks created for new raid set
[ 2543.927357] md/raid1:mdX: not clean -- starting background reconstruction
[ 2543.928403] md/raid1:mdX: active with 2 out of 2 mirrors
[ 2544.042790] mdX: bitmap file is out of date, doing full recovery
[ 2544.143245] md: resync of RAID array mdX
  Logical volume "lv_mirror" created.

[root@dlp ~]#
lvdisplay /dev/vg_mirror/lv_mirror

  --- Logical volume ---
  LV Path                /dev/vg_mirror/lv_mirror
  LV Name                lv_mirror
  VG Name                vg_mirror
  LV UUID                coKLtX-CV30-l2Bm-64go-WdSR-or7k-2roKcK
  LV Write Access        read/write
  LV Creation host, time dlp.srv.world, 2020-02-06 21:02:10 +0900
  LV Status              available
  # open                 0
  LV Size                50.00 GiB
  Current LE             12800
  Mirrored volumes       2
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:6
[2] Iif you'd like to set mirroring volume from a normal logical volume which is already running, Configure like follows.
# extend volume group

[root@dlp ~]#
vgextend vg_data /dev/sdc1

  Volume group "vg_data" successfully extended

# set mirroring volume

[root@dlp ~]#
lvconvert -m1 /dev/vg_data/lv_data /dev/sdc1

Are you sure you want to convert linear LV vg_data/lv_data to raid1 with 2 images enhancing resilience? [y/n]: y
[ 3004.182907] device-mapper: raid: Device 1 specified for rebuild; clearing superblock
[ 3004.184179] device-mapper: raid: Superblocks created for new raid set
[ 3004.198075] md/raid1:mdX: active with 1 out of 2 mirrors
[ 3004.280198] mdX: bitmap file is out of date, doing full recovery
[ 3004.340224] md: recovery of RAID array mdX
  Logical volume vg_data/lv_data successfully converted.

# confirm (complete to sync if [Cpy%Sync] turns [100])

[root@dlp ~]#
lvs

  LV      VG      Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root    cl      -wi-ao---- <26.00g
  swap    cl      -wi-ao----   3.00g
  lv_data vg_data rwi-a-r---  50.00g                                    3.95
[3] Unset Mirroring Volume like follows if you want.
# specify -m0 to unset

[root@dlp ~]#
lvconvert -m0 /dev/vg_data/lv_data

Are you sure you want to convert raid1 LV vg_data/lv_data to type linear losing all resilience? [y/n]: y
  Logical volume vg_data/lv_data successfully converted.

[root@dlp ~]#
lvs -a -o vg_name,name,devices,size

  VG      LV      Devices        LSize
  cl      root    /dev/sda2(768) <26.00g
  cl      swap    /dev/sda2(0)     3.00g
  vg_data lv_data /dev/sdb1(0)    50.00g
Matched Content