LVM : Configure Mirroring Volume2024/12/27 |
Configure Mirroring Volumes. It is like RAID 1. |
|
[1] | For example, create a Mirroring Volume with Physical Volume [/dev/sdb1] and [/dev/sdc1]. |
# create volume 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 [ 88.658088] raid6: skipped pq benchmark and selected avx512x4 [ 88.658095] raid6: using avx512x2 recovery algorithm [ 88.659560] async_tx: api initialized (async) [ 88.661026] xor: automatically using best checksumming function avx [ 88.722878] device-mapper: raid: Superblocks created for new raid set [ 88.733129] md/raid1:mdX: not clean -- starting background reconstruction [ 88.733135] md/raid1:mdX: active with 2 out of 2 mirrors [ 88.760839] mdX: bitmap file is out of date, doing full recovery [ 88.765572] 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 cUwCVy-Bkdp-CifE-kAwu-rLaW-k1HZ-vgnmiE LV Write Access read/write LV Creation host, time dlp.srv.world, 2024-12-27 09:55:03 +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:7 |
[2] | If you'd like to set mirroring volume from a normal logical volume which is already running, Configure like follows. |
# extend the 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
[ 284.587442] device-mapper: raid: Device 1 specified for rebuild; clearing superblock
[ 284.587449] device-mapper: raid: Superblocks created for new raid set
[ 284.600591] md/raid1:mdX: active with 1 out of 2 mirrors
[ 284.610769] mdX: bitmap file is out of date, doing full recovery
[ 284.624064] md: recover of RAID array mdX
Logical volume vg_data/lv_data successfully converted.
# verify status # complete to sync if [Cpy%Sync] turns to [100] [root@dlp ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert home cs -wi-ao---- <23.34g root cs -wi-ao---- 47.79g swap cs -wi-ao---- <7.87g lv_data vg_data rwi-a-r--- 30.00g 10.18[root@dlp ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert home cs -wi-ao---- <23.34g root cs -wi-ao---- 47.79g swap cs -wi-ao---- <7.87g lv_data vg_data rwi-a-r--- 30.00g 100.00 |
[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 cs home /dev/sda3(2014) <23.34g cs root /dev/sda3(7988) 47.79g cs swap /dev/sda3(0) <7.87g vg_data lv_data /dev/sdb1(0) 30.00g |
Sponsored Link |
|