jxb@pg2:~$ sudo pvcreate /dev/xvdg Physical volume "/dev/xvdg" successfully created jxb@pg2:~$ sudo vgextend db /dev/xvdg Volume group "db" successfully extended jxb@pg2:~$ sudo lvextend db/pg1 -L 70G Using stripesize of last segment 4.00 KiB Rounding size (17920 extents) down to stripe boundary size for segment (17919 extents) Extending logical volume pg1 to 70.00 GiB Insufficient free space: 2814 extents needed, but only 2811 available
可以看到只有一个物理盘的时候无法扩展逻辑盘
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
jxb@pg2:~$ sudo pvcreate /dev/xvdi Physical volume "/dev/xvdi" successfully created jxb@pg2:~$ sudo pvcreate /dev/xvdh Physical volume "/dev/xvdh" successfully created jxb@pg2:~$ sudo vgextend db /dev/xvdi Volume group "db" successfully extended jxb@pg2:~$ sudo vgextend db /dev/xvdh Volume group "db" successfully extended jxb@pg2:~$ vgs WARNING: Running as a non-root user. Functionality may be unavailable. No volume groups found jxb@pg2:~$ sudo vgs VG #PV #LV #SN Attr VSize VFree db 6 1 0 wz--n- 89.98g 30.97g jxb@pg2:/u$ sudo lvextend -l+100%free db/pg1 Using stripesize of last segment 4.00 KiB Extending logical volume pg1 to 89.98 GiB Logical volume pg1 successfully resized
查看 Stripe 逻辑盘信息
1 2 3 4
jxb@pg2:/u$ sudo lvs --segments LV VG Attr #Str Type SSize pg1 db -wi-ao 3 striped 59.99g pg1 db -wi-ao 3 striped 29.99g
调整逻辑盘大小
调整前已经使用了 76%
1 2 3
jxb@pg2:/u$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/db-pg1 59G 43G 14G 76% /u
执行调整操作
1 2 3 4 5 6
jxb@pg2:/u$ sudo resize2fs /dev/mapper/db-pg1 resize2fs 1.42 (29-Nov-2011) Filesystem at /dev/mapper/db-pg1 is mounted on /u; on-line resizing required old_desc_blocks = 4, new_desc_blocks = 6 Performing an on-line resize of /dev/mapper/db-pg1 to 23586816 (4k) blocks. The filesystem on /dev/mapper/db-pg1 is now 23586816 blocks long.
调整后 降为 51%
1 2 3
jxb@pg2:/u$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/db-pg1 90G 43G 43G 51% /u