LVM でVG を構成しているディスクが壊れそうな時の移行方法を検討した。
pvmove コマンドを使って移すのが楽そう。
あいにく(?)壊れそうなディスクがないので、NAS の領域の一部をiSCSI で切り出して確認。
iSCSIログイン。
# iscsiadm -m discovery -t sendtargets -p 192.168.1.8
# iscsiadm -m discovery -t sendtargets -p 192.168.1.9
# iscsiadm -m node -T iqn.2011-03.com.yasu-hide:nas00.vol1 --login
# iscsiadm -m node -T iqn.2011-03.com.yasu-hide:nas01.vol1 --login
生えたmultipath デバイスにパーティションが存在していないことを確認。
# fdisk -l /dev/mpath/mpath1
Disk /dev/mpath/mpath1: 171.7 GB, 171798691840 bytes
255 heads, 63 sectors/track, 20886 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/mpath/mpath1 doesn't contain a valid partition table
領域を作成。
# fdisk /dev/mapper/mpath1
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 20886.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-20886, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-20886, default 20886):
Using default value 20886
Command (m for help): p
Disk /dev/mapper/mpath1: 171.7 GB, 171798691840 bytes
255 heads, 63 sectors/track, 20886 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/mapper/mpath1p1 1 20886 167766763+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
# kpartx -a /dev/mapper/mpath1
新領域にPV を作成する。
# pvcreate /dev/mapper/mpath1p1
Physical volume "/dev/mapper/mpath1p1" successfully created
作成したPV を移行元が存在するVG にくっつける。
# vgextend VG0 /dev/mpath/mpath1p1
Volume group "VG0" successfully extended
src,dst のデバイスを指定してpvmoveを実行。
# pvmove -v /dev/mpath/mpath0p1 /dev/mpath/mpath1p1
Finding volume group "VG0"
Archiving volume group "VG0" metadata (seqno 7).
Creating logical volume pvmove0
Moving 500 extents of logical volume VG0/LV1
Moving 1000 extents of logical volume VG0/LV2
Moving 1250 extents of logical volume VG0/LV3
Moving 5120 extents of logical volume VG0/pv-mvtest00
Moving 5120 extents of logical volume VG0/pv-mvtest01
Found volume group "VG0"
activation/volume_list configuration setting not defined, checking only host tags for VG0/LV1
Found volume group "VG0"
activation/volume_list configuration setting not defined, checking only host tags for VG0/LV2
Found volume group "VG0"
activation/volume_list configuration setting not defined, checking only host tags for VG0/LV3
Found volume group "VG0"
activation/volume_list configuration setting not defined, checking only host tags for VG0/pv-mvtest00
Found volume group "VG0"
activation/volume_list configuration setting not defined, checking only host tags for VG0/pv-mvtest01
Updating volume group metadata
Found volume group "VG0"
Found volume group "VG0"
Suspending VG0-LV1 (253:2) with device flush
Found volume group "VG0"
Found volume group "VG0"
Suspending VG0-LV2 (253:3) with device flush
Found volume group "VG0"
Found volume group "VG0"
Suspending VG0-LV3 (253:4) with device flush
Found volume group "VG0"
Found volume group "VG0"
Suspending VG0-pv--mvtest00 (253:5) with device flush
Found volume group "VG0"
Found volume group "VG0"
Suspending VG0-pv--mvtest01 (253:6) with device flush
Found volume group "VG0"
activation/volume_list configuration setting not defined, checking only host tags for VG0/pvmove0
Creating VG0-pvmove0
Loading VG0-pvmove0 table (253:9)
Resuming VG0-pvmove0 (253:9)
Found volume group "VG0"
Loading VG0-pvmove0 table (253:9)
Suppressed VG0-pvmove0 identical table reload.
Loading VG0-LV1 table (253:2)
Resuming VG0-LV1 (253:2)
Found volume group "VG0"
Loading VG0-pvmove0 table (253:9)
Suppressed VG0-pvmove0 identical table reload.
Loading VG0-LV2 table (253:3)
Resuming VG0-LV2 (253:3)
Found volume group "VG0"
Loading VG0-pvmove0 table (253:9)
Suppressed VG0-pvmove0 identical table reload.
Loading VG0-LV3 table (253:4)
Resuming VG0-LV3 (253:4)
Found volume group "VG0"
Loading VG0-pvmove0 table (253:9)
Suppressed VG0-pvmove0 identical table reload.
Loading VG0-pv--mvtest00 table (253:5)
Resuming VG0-pv--mvtest00 (253:5)
Found volume group "VG0"
Loading VG0-pvmove0 table (253:9)
Suppressed VG0-pvmove0 identical table reload.
Loading VG0-pv--mvtest01 table (253:6)
Resuming VG0-pv--mvtest01 (253:6)
Creating volume group backup "/etc/lvm/backup/VG0" (seqno 8).
Checking progress before waiting every 15 seconds
/dev/mpath/mpath0p1: Moved: 0.0%
<snip>
/dev/mpath/mpath0p1: Moved: 100.0%
移行が完了したら、壊れそうな移行元ディスクをreduceする。
# vgreduce VG0 /dev/mpath/mpath0p1
Removed "/dev/mpath/mpath0p1" from volume group "VG0"
壊れそうなディスクはLVM から抹消。
# pvremove /dev/mpath/mpath0p1
Labels on physical volume "/dev/mpath/mpath0p1" successfully wiped
multipath デバイスの名前を元に戻すため、binding ファイルを削除。
他にもデバイスを使っている場合は編集するのが吉。
# rm -f /var/lib/multipath/bindings
壊れそうなディスクを完全に切り離す。
# iscsiadm -m node -T iqn.2011-03.com.yasu-hide:nas00.vol0 --logout
# iscsiadm -m node -T iqn.2011-03.com.yasu-hide:nas01.vol0 --logout
要するに、pvmove コマンドを使ってみたかっただけ。
![]() | Linux RAID入門 武田 保真 技術評論社 2007-06-04 売り上げランキング : 449005 Amazonで詳しく見る by G-Tools |
コメント