Rocky Linux 8
Sponsored Link

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

 
ミラーリング論理ボリュームの作成方法です。
[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

[  211.634519] raid6: sse2x1   gen() 13407 MB/s
[  211.651498] raid6: sse2x1   xor()  7802 MB/s
[  211.668499] raid6: sse2x2   gen() 14909 MB/s
[  211.685497] raid6: sse2x2   xor()  9596 MB/s
[  211.702474] raid6: sse2x4   gen() 15373 MB/s
[  211.719495] raid6: sse2x4   xor()  6706 MB/s
[  211.736494] raid6: avx2x1   gen() 25409 MB/s
[  211.753492] raid6: avx2x1   xor() 14189 MB/s
[  211.770470] raid6: avx2x2   gen() 28151 MB/s
[  211.787491] raid6: avx2x2   xor() 16780 MB/s
[  211.804490] raid6: avx2x4   gen() 28382 MB/s
[  211.821489] raid6: avx2x4   xor()  9060 MB/s
[  211.822143] raid6: using algorithm avx2x4 gen() 28382 MB/s
[  211.822944] raid6: .... xor() 9060 MB/s, rmw enabled
[  211.823668] raid6: using avx2x2 recovery algorithm
[  211.825543] async_tx: api initialized (async)
[  211.827868] xor: automatically using best checksumming function   avx
[  211.848178] device-mapper: raid: Loading target version 1.15.1
[  211.966127] device-mapper: raid: Superblocks created for new raid set
[  211.997568] md/raid1:mdX: not clean -- starting background reconstruction
[  211.998611] md/raid1:mdX: active with 2 out of 2 mirrors
[  212.239445] mdX: bitmap file is out of date, doing full recovery
[  212.295174] 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                H8a1z5-r759-QLqb-kIyf-CU4H-RGUd-6kgnRb
  LV Write Access        read/write
  LV Creation host, time dlp.srv.world, 2021-07-20 20:08:18 +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_dlp /dev/sdc1

  Volume group "vg_dlp" successfully extended

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

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

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

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

[root@dlp ~]#
lvs

  LV      VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root    rl     -wi-ao---- <26.00g
  swap    rl     -wi-ao----   3.00g
  lv_data vg_dlp rwi-a-r---  30.00g                                    15.70

[root@dlp ~]#
lvs

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

[root@dlp ~]#
lvconvert -m0 /dev/vg_mirror/lv_mirror

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

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

  VG        LV        Devices        LSize
  rl        root      /dev/sda2(768) <26.00g
  rl        swap      /dev/sda2(0)     3.00g
  vg_mirror lv_mirror /dev/sdb1(1)    50.00g
関連コンテンツ