|
傳統分區概念
|
LVM
邏輯卷管理
|
磁盤空間獨立性 |
不能充分利用,尤爲是一個FS只能對應一個分區 |
多磁盤PV組成存儲池VG,再根據應用細分邏輯卷LV,空間利用率提升 |
空間擴展性 |
從新分區 |
採起靜態或動態在線擴展卷組容量 |
數據備份 |
業務繁忙時,I/O接口讀寫頻繁 |
可採起快照方式捕捉某一邏輯卷的瞬間精確拷貝已完成在線備份工做 |
用戶使用性 |
分區標識沒法知足大量用戶要求 |
可根據用戶需求定義lv邏輯卷的卷標 |
1、建立LVM的準備工做
1.搭建環境:OS:RHEL5.3
LVM包
IDE磁盤/dev/hdb(1024MB),/dev/hdd(1024MB)
2.轉換磁盤分區——>lvm卷分區
最終方案:/dev/hdb ——> 建立 /dev/hdb1(Id:5,System:Extended)
/dev/hdb5(Id:8e,System:Linux LVM)
/dev/hdd ——> 建立 /dev/hdd1(Id:5,System:Extended)
/dev/hdd5(Id:8e,System:Linux LVM)
操做:(僅以/dev/hdb爲例)
#fdisk /dev/hdb
#p(顯示分區狀況)——>#n(新建分區)——>#e(建立擴展分區)——>#l(建立邏輯分區)
#此處爲實驗環境方便後面的增減操做,因此咱們將/dev/hdb所有劃分爲一個分區
#t(設置磁盤Hex code)——>#8e(LinuxLVM)——>#w(保存操做)
#p
Disk /dev/hdb: 1073 MB, 1073741824 bytes
16 heads, 63 sectors/track, 2080 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 2080 1048288+ 5 Extended
/dev/hdb5 1 2080 1048257 8e Linux LVM
#partprobe (此命令讓kernel會從新讀取磁盤分區表,修改生效)
|
2、建立LVM
1.建立PV盤
方案: /dev/hdb ——> lvm2[1024MB]
/dev/hdd ——> lvm2[1024MB]
操做:
#pvcreate /dev/hdb5 /dev/hdd5
#pvscan
#pvdisplay
"/dev/hdb5" is a new physical volume of "1023.69 MB"
--- NEW Physical volume ---
PV Name /dev/hdb5
VG Name
PV Size 1023.69 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID zM7103-SJg4-ZjOb-BeL0-dlR1-HHh6-HCG8kG
"/dev/hdd5" is a new physical volume of "1023.69 MB"
--- NEW Physical volume ---
PV Name /dev/hdd5
VG Name
PV Size 1023.69 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID hAk1Dx-QulA-YV4G-p8wa-7sWw-FiaC-10GorS
|
2.建立VG存儲池
方案: lvm2(/dev/hdb)——> vg1
lvm2(/dev/hdd)——> vg2
操做:
#vgcreate vg1 /dev/hdb5 #vgcreate vg2 /dev/hdd5 #vgscan #vgdisplay
--- Volume group --- VG Name vg2 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 1020.00 MB PE Size 4.00 MB Total PE 255 Alloc PE / Size 0 / 0 Free PE / Size 255 / 1020.00 MB VG UUID Wa4Jo8-k3xY-BTng-uV6j-0Ee1-Vp8b-fNVrhQ
--- Volume group --- VG Name vg1 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 1020.00 MB PE Size 4.00 MB Total PE 255 Alloc PE / Size 0 / 0 Free PE / Size 255 / 1020.00 MB VG UUID UGjfZd-shth-ZRTU-sVVm-MD0s-wzVB-zd7Uwt
|
3.分配LV邏輯卷
方案: work(/dev/hdb5)——> vg1
Study(/dev/hdd5)——> vg2
操做:
#lvcreate –L 500M –n work vg1 #lvcreate –L 500M –n study vg2 #lvscan #lvdisplay
--- Logical volume --- LV Name /dev/vg2/study VG Name vg2 LV UUID 53VT9v-dyp0-lSST-eDFz-w2Ns-Os0Z-ERnqVU LV Write Access read/write LV Status available # open 0 LV Size 500.00 MB Current LE 125 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1
--- Logical volume --- LV Name /dev/vg1/work VG Name vg1 LV UUID lhgKVg-hi95-W9gw-wOkZ-uyuy-BgZp-RrsCcA LV Write Access read/write LV Status available # open 0 LV Size 500.00 MB Current LE 125 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0
|
4.分區格式化
#mkfs.ext3 /dev/vg1/work //或 #mkfs -j /dev/vg1/work #mkfs.ext3 /dev/vg2/study //... #df –l Disk /dev/hda: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 * 1 32 257008+ 83 Linux /dev/hda2 33 97 522112+ 83 Linux /dev/hda3 98 358 2096482+ 83 Linux /dev/hda4 359 1044 5510295 5 Extended /dev/hda5 359 549 1534176 83 Linux /dev/hda6 550 848 2401686 83 Linux /dev/hda7 849 913 522081 82 Linux swap / Solaris /dev/hda8 914 978 522081 83 Linux /dev/hda9 979 1043 522081 83 Linux Disk /dev/hdb: 1073 MB, 1073741824 bytes 16 heads, 63 sectors/track, 2080 cylinders Units = cylinders of 1008 * 512 = 516096 bytes Device Boot Start End Blocks Id System /dev/hdb1 1 2080 1048288+ 5 Extended /dev/hdb5 1 2080 1048257 8e Linux LVM Disk /dev/hdd: 1073 MB, 1073741824 bytes 16 heads, 63 sectors/track, 2080 cylinders Units = cylinders of 1008 * 512 = 516096 bytes Device Boot Start End Blocks Id System /dev/hdd1 1 2080 1048288+ 5 Extended /dev/hdd5 1 2080 1048257 8e Linux LVM
|
5.掛載新分區
#mkdir ../home/work ../home/study #mount ../dev/vg1/work ../home/work #mount ../dev/vg2/study ../home/study #df –Th Filesystem Type Size Used Avail Use% Mounted on /dev/hda2 ext3 494M 212M 257M 46% / /dev/hda9 ext3 494M 45M 425M 10% /var /dev/hda8 ext3 494M 11M 458M 3% /opt /dev/hda6 ext3 2.3G 68M 2.1G 4% /home /dev/hda3 ext3 2.0G 1.7G 182M 91% /usr /dev/hda5 ext3 1.5G 35M 1.4G 3% /usr/local /dev/hda1 ext3 244M 12M 219M 6% /boot tmpfs tmpfs 125M 0 125M 0% /dev/shm
/dev/mapper/vg1-work ext3 485M 11M 449M 3% /home/work /dev/mapper/vg2-study ext3 485M 11M 449M 3% /home/study
|