CentOS Stream 8
Sponsored Link

LVM : 論理ボリュームのミラーリング2021/03/08

 
ミラーリング論理ボリュームの作成方法です。
[1] 例として、物理ボリューム [/dev/sdb1] と [/dev/sdc1] を使用してミラーリングボリュームを作成します。
# [/dev/sdb1] と [/dev/sdc1] でボリュームグループ [vg_mirror] を作成

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

  Volume group "vg_mirror" successfully created

# ミラー論理ボリューム作成

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

[ 1101.040596] raid6: sse2x1   gen() 11960 MB/s
[ 1101.058579] raid6: sse2x1   xor()  7586 MB/s
[ 1101.076584] raid6: sse2x2   gen() 13040 MB/s
[ 1101.094582] raid6: sse2x2   xor()  9199 MB/s
[ 1101.112586] raid6: sse2x4   gen() 13943 MB/s
[ 1101.130587] raid6: sse2x4   xor()  5827 MB/s
[ 1101.148585] raid6: avx2x1   gen() 14740 MB/s
[ 1101.166583] raid6: avx2x1   xor() 13388 MB/s
[ 1101.184582] raid6: avx2x2   gen() 18628 MB/s
[ 1101.202580] raid6: avx2x2   xor() 16235 MB/s
[ 1101.220579] raid6: avx2x4   gen() 20438 MB/s
[ 1101.238564] raid6: avx2x4   xor()  5846 MB/s
[ 1101.239618] raid6: using algorithm avx2x4 gen() 20438 MB/s
[ 1101.240966] raid6: .... xor() 5846 MB/s, rmw enabled
[ 1101.242189] raid6: using avx2x2 recovery algorithm
[ 1101.244508] async_tx: api initialized (async)
[ 1101.246846] xor: automatically using best checksumming function   avx
[ 1101.267096] device-mapper: raid: Loading target version 1.15.1
[ 1101.319169] device-mapper: raid: Superblocks created for new raid set
[ 1101.330455] md/raid1:mdX: not clean -- starting background reconstruction
[ 1101.331515] md/raid1:mdX: active with 2 out of 2 mirrors
[ 1101.463414] mdX: bitmap file is out of date, doing full recovery
[ 1101.483596] 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                Cg00Sz-UwGv-Te4S-Xn1p-MJcD-AXwd-Xt1mDU
  LV Write Access        read/write
  LV Creation host, time dlp.srv.world, 2021-03-07 16:22:32 +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] すでに稼働中の論理ボリュームをミラー化する場合は以下のように設定します。
# ボリュームグループ拡張

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

  Volume group "vg_data" successfully extended

# 論理ボリュームミラー化

[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
[ 1386.352582] device-mapper: raid: Device 1 specified for rebuild; clearing superblock
[ 1386.354375] device-mapper: raid: Superblocks created for new raid set
[ 1386.363010] md/raid1:mdX: active with 1 out of 2 mirrors
[ 1386.496302] mdX: bitmap file is out of date, doing full recovery
[ 1386.517129] md: recovery of RAID array mdX
  Logical volume vg_data/lv_data successfully converted.

# 確認 : [Cpy%Sync] が [100] でデータ同期完了

[root@dlp ~]#
lvs

  LV      VG      Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root    cs      -wi-ao---- 71.00g
  swap    cs      -wi-ao----  7.90g
  lv_data vg_data rwi-a-r--- 50.00g                                    13.12

[root@dlp ~]#
lvs

  LV      VG      Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root    cs      -wi-ao---- 71.00g
  swap    cs      -wi-ao----  7.90g
  lv_data vg_data rwi-a-r--- 50.00g                                    100.00
[3] 論理ボリュームのミラー化を解除する場合は以下のように設定します。
# -m0 で解除

[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      root    /dev/sda2(7994) 71.00g
  cs      root    /dev/sda2(2023) 71.00g
  cs      swap    /dev/sda2(0)     7.90g
  vg_data lv_data /dev/sdb1(0)    50.00g
関連コンテンツ