繼上章 Oracle Linux Install Using LVM,我們談到 LVM 的好處在於可以動態放大檔案系統,接下來就來做做看,假設我們安裝 Oracle Linux 時的磁碟配置如下,Volume Group:vg0 有三個 Physical Volume 實體磁區(簡稱PV),依下圖的配置來看,vg0 還有大約 13 G 未分配的磁碟空間。
下圖是整個系統磁碟的配置情況:
系統安裝完後,可以用指令 lvscan 來查詢 LVM 實際擁有的空間
[root@oradb12clinux ~]# lvscan ACTIVE '/dev/vg0/lv_u01' [15.00 GiB] inherit ACTIVE '/dev/vg0/lv_root' [10.00 GiB] inherit ACTIVE '/dev/vg0/lv_swap' [4.00 GiB] inherit ACTIVE '/dev/vg0/lv_opt' [8.00 GiB] inherit |
也可以使用指令 df -h 來看各個磁碟現在的使用狀況
[root@oradb12clinux ~]# df -h |
用指令 vgdisplay 查詢一下 Volume Group:vg0 是否有未分配的磁碟空間
[root@oradb12clinux oradb12c]# vgdisplay --- Volume group --- VG Name vg0 System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 7 VG Access read/write VG Status resizable MAX LV 0 Cur LV 4 Open LV 4 Max PV 0 Cur PV 3 Act PV 3 VG Size 49.99 GiB PE Size 4.00 MiB Total PE 12797 Alloc PE / Size 10521 / 41.10 GiB Free PE / Size 2276 / 8.89 GiB VG UUID MJcTqC-prDM-v0Ys-4s2c-0Fze-vGFD-THI2Iw |
當發生磁碟空間不足,而 vg0 仍有未分配的磁碟空間時,就可以利用指令 lvextend -L 來增大空間,這樣是不是很方便呢!!
[root@oradb12clinux ~]# lvextend -L +100M '/dev/vg0/lv_opt' ot@oradb12clinux oradb12c]# lvextend -L +4096 '/dev/vg0/lv_root'
|
發現了沒?! Logical Volume 邏輯磁區(簡稱 LV)'/dev/vg0/lv_root' 變大了,變為 14G,但用 df -h 去看時仍為 9.9 G ,lv_opt 也是相同的情形,那是因為尚未讓系統知道磁碟空間己變大,可以使用 resize2fs 來讓系統重新分配,若出現 Cannot use resize2fs as it is online. Use ext2online instead. 訊息,則是告知您,因磁碟在online 的情況下不能使用指令 resize2fs ,需以指令 ext2online 來替代。
[root@oradb12clinux oradb12c]# resize2fs /dev/vg0/lv_root [root@oradb12clinux oradb12c]# resize2fs /dev/vg0/lv_opt [root@oradb12clinux oradb12c]# df -h |
再查詢一次,看吧!! 系統也同步將空間實際放大了
附註:若要看各個 Logical Volume 邏輯磁區(簡稱 LV)的狀態,可以用指令lvdisplay 查詢
[root@oradb12clinux oradb12c]# lvdisplay --- Logical volume --- LV Path /dev/vg0/lv_u01 LV Name lv_u01 VG Name vg0 LV UUID qEiPkX-e9tf-SZow-0lWO-mani-vVG5-z8z3Su LV Write Access read/write LV Creation host, time oradb12clinux.globeunion.com, 2013-10-24 00:26:18 +0800 LV Status available # open 1 LV Size 15.00 GiB Current LE 3840 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:2 --- Logical volume --- LV Path /dev/vg0/lv_root LV Name lv_root VG Name vg0 LV UUID 0O3A7O-Lecx-bYK8-orvi-HaG3-Wc9h-OdqZbq LV Write Access read/write LV Creation host, time oradb12clinux.globeunion.com, 2013-10-24 00:26:26 +0800 LV Status available # open 1 LV Size 14.00 GiB Current LE 3584 Segments 3 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:0 --- Logical volume --- LV Path /dev/vg0/lv_swap LV Name lv_swap VG Name vg0 LV UUID gV4fRO-FSVF-F7H2-pL9X-qJef-IfUO-mO6oLN LV Write Access read/write LV Creation host, time oradb12clinux.globeunion.com, 2013-10-24 00:26:27 +0800 LV Status available # open 2 LV Size 4.00 GiB Current LE 1024 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:1 --- Logical volume --- LV Path /dev/vg0/lv_opt LV Name lv_opt VG Name vg0 LV UUID 18OarF-nVXJ-er3a-WsYn-lKJT-LEyJ-1YHcKr LV Write Access read/write LV Creation host, time oradb12clinux.globeunion.com, 2013-10-24 00:26:27 +0800 LV Status available # open 1 LV Size 8.10 GiB Current LE 2073 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:3 |
參考:
留言列表