LVM PV级数据迁移

一、环境描述

现网的物理硬盘总共17GB,使用一块30GB的新硬盘代替17GB硬盘,然后进行PV数据迁移

二、迁移步骤

2.1 添加一块磁盘创建PV

[root@localhost ~]# pvcreate /dev/sdc
  Physical volume "/dev/sdc" successfully created
[root@localhost ~]# pvs
  PV         VG         Fmt  Attr PSize  PFree
  /dev/sda2  VolGroup00 lvm2 a-   20.88G     0
  /dev/sdb   vg00       lvm2 a-   16.00G     0
  /dev/sdc              lvm2 a-   30.00G 30.00G

2.2 添加新PV到vg00卷组中

[root@localhost ~]# vgextend vg00 /dev/sdc
  Volume group "vg00" successfully extended
[root@localhost ~]# vgs
  VG         #PV #LV #SN Attr   VSize  VFree
  VolGroup00   1   2   0 wz--n- 20.88G     0
  vg00         2   1   0 wz--n- 45.99G 30.00G

2.3 源PV数据盘 迁移到 新PV数据盘上

[root@localhost ~]# pvmove /dev/sdb /dev/sdc
  /dev/sdb: Moved: 0.0%
  /dev/sdb: Moved: 16.0%
  /dev/sdb: Moved: 25.9%
  /dev/sdb: Moved: 44.6%
  /dev/sdb: Moved: 62.2%
  /dev/sdb: Moved: 77.9%
  /dev/sdb: Moved: 94.6%
  /dev/sdb: Moved: 100.0%
[root@localhost ~]# pvs
  PV         VG         Fmt  Attr PSize  PFree
  /dev/sda2  VolGroup00 lvm2 a-   20.88G     0
  /dev/sdb   vg00       lvm2 a-   16.00G 16.00G
  /dev/sdc   vg00       lvm2 a-   30.00G 14.00G

2.4 从VG中移除已替换的旧PV

[root@localhost ~]# vgreduce vg00 /dev/sdb
  Removed "/dev/sdb" from volume group "vg00"
[root@localhost ~]# vgs
  VG         #PV #LV #SN Attr   VSize  VFree
  VolGroup00   1   2   0 wz--n- 20.88G     0
  vg00         1   1   0 wz--n- 30.00G 14.00G

2.5 移除源PV

[root@localhost ~]# pvremove /dev/sdb
  Labels on physical volume "/dev/sdb" successfully wiped
[root@localhost ~]# pvs
  PV         VG         Fmt  Attr PSize  PFree
  /dev/sda2  VolGroup00 lvm2 a-   20.88G     0
  /dev/sdc   vg00       lvm2 a-   30.00G 14.00G

2.6 扩容LV

[root@localhost ~]# lvs
  LV       VG         Attr   LSize  Origin Snap%  Move Log Copy%  Convert
  LogVol00 VolGroup00 -wi-ao 16.97G
  LogVol01 VolGroup00 -wi-ao  3.91G
  lv00     vg00       -wi-ao 16.00G
[root@localhost ~]# lvextend -l +100%FREE -r /dev/vg00/lv00
  Extending logical volume lv00 to 30.00 GB
  Logical volume lv00 successfully resized
tune2fs: Filesystem has unsupported feature(s) while trying to open /dev/mapper/vg00-lv00
Couldn't find valid filesystem superblock.
fsadm: Cannot parse tune2fs output
  fsadm failed: 1
[root@localhost ~]# lvs
  LV       VG         Attr   LSize  Origin Snap%  Move Log Copy%  Convert
  LogVol00 VolGroup00 -wi-ao 16.97G
  LogVol01 VolGroup00 -wi-ao  3.91G
  lv00     vg00       -wi-ao 30.00G

你可能感兴趣的:(LVM PV级数据迁移)