CentOS 6
Sponsored Link

論理ボリュームのミラーリング2015/07/18

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

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

  Logical volume "vg_mirror" created
# ミラー論理ボリューム作成

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

[ 5133.283498] device-mapper: raid: Superblocks created for new array
[ 5133.285922] md/raid1:mdX: not clean -- starting background reconstruction
[ 5133.287095] md/raid1:mdX: active with 2 out of 2 mirrors
[ 5133.287932] Choosing daemon_sleep default (5 sec)
[ 5133.288688] created bitmap (50 pages) for device mdX
[ 5133.334556] mdX: bitmap file is out of date, doing full recovery
[ 5133.667257] mdX: bitmap initialized from disk: read 4 pages, set 102400 of 102400 bits
[ 5133.747852] md: resync of RAID array mdX
[ 5133.748596] md: minimum _guaranteed_  speed: 1000 KB/sec/disk.
[ 5133.749676] md: using maximum available idle IO bandwidth (but not more than 200000 KB/sec) for resync.
[ 5133.751277] md: using 128k window, over a total of 52428800k.
  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                P8dakZ-TiWn-T6b5-y6A7-Ecty-ieRZ-vGZAWX
  LV Write Access        read/write
  LV Creation host, time dlp.srv.world, 2015-07-20 13:18:20 +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

[ 5710.014313] device-mapper: raid: Superblocks created for new array
[ 5710.019478] md/raid1:mdX: not clean -- starting background reconstruction
[ 5710.020597] md/raid1:mdX: active with 2 out of 2 mirrors
[ 5710.021499] Choosing daemon_sleep default (5 sec)
[ 5710.022279] created bitmap (50 pages) for device mdX
[ 5710.173412] mdX: bitmap file is out of date, doing full recovery
[ 5710.466100] mdX: bitmap initialized from disk: read 4 pages, set 102400 of 102400 bits
[ 5710.567058] md: resync of RAID array mdX
[ 5710.567705] md: minimum _guaranteed_  speed: 1000 KB/sec/disk.
[ 5710.568658] md: using maximum available idle IO bandwidth (but not more than 200000 KB/sec) for resync.
[ 5710.570204] md: using 128k window, over a total of 52428800k.

# 確認 (Cpy%Sync が 100 でデータ同期完了)

[root@dlp ~]#
lvs

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

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

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

  VG      LV      Devices        LSize
  centos  root    /dev/sda2(996) 45.62g
  centos  swap    /dev/sda2(0)    3.89g
  vg_data lv_data /dev/sdb1(0)   50.00g
関連コンテンツ