LVM為Logical Volume
Manager的縮寫,起源于早期的UNIX系統,lvm提供了一種更高級的磁盤管理服務和工具集,為了方便磁盤管理和劃分,它將幾個物理磁盤或分區組成
一個更大的磁盤組,再在磁盤組上進行分區劃分或者裸設備劃分.跟單個磁盤的管理比起來它提供了一種更加靈活的磁盤管理服務,可以在線動態的調整分區的大小
和容量擴展,可以實現文件系統跨域不同的磁盤和分區,實現磁盤的條帶。隨著技術的發展,LVM還已經融入到了cluster當中.RedHat的
LVM2(對LVM的升級)就可以支持cluster 環境了.cluster 環境中,一臺主機對共享存儲建立了LVM后,可以動態同步到其他節點。
LVM總體有三部分組成,
底層是組成LV的物理卷,LV的數據都存儲在這些物理卷上,這些物理卷可以是整塊磁盤也可以是單個分區,這些磁盤或分區在加入LVM卷組前必須通過LVM
提供的命令進行格式化,將每個磁盤或分區格式化成可以被LVM識別的PE(Physical
Extents)單位;中間是卷組,由物理卷組成的一個大的邏輯磁盤組;最上面一層就是邏輯卷了,
相當于一個磁盤分區,跟磁盤分區不同的是我們可以創建Linear(直線)、striped(條帶),mirrord(鏡像)三種邏輯卷,linear的
創建方式就是類似于我們在普通磁盤上創建的分區模式,每個邏輯卷底層又被分割成最小的LE(Logical Extents)
可被尋址的基本單位,在同一個卷組中LE跟每一個PE是對應的.
物理介質
系統的存儲設備:硬盤,如:/dev/hda1、/dev/sda等等,是存儲系統最低層的存儲單元。
物理卷
LVM的底層存儲容器,LVM的基本存儲塊,是LVM格式化后的物理介質,最終是由被LVM格式化的PE單元組成.。
卷組
類似于非LVM系統中的物理硬盤,由物理卷組成。可以在卷組上創建一個或多個LVM分區(邏輯卷),LVM卷組由一個或多個物理卷組成。
邏輯卷
類似于非LVM系統中的硬盤分區,在邏輯卷之上可以建立文件系統(比如/home、/oracle),或者可以當裸設備使用。
PE
每個物理卷被劃分為稱為PE(Physical Extents)的基本單元,具有唯一編號的PE是可以被LVM尋址的最小單元。PE的大小是可以配置的,默認為4MB。
LE
邏輯卷也被劃分為被稱為LE(Logical Extents) 的可被尋址的基本單位。同一個卷組中,LE的大小和PE是相同的,并且一一對應。
每個操作系統都提供了自己的一系列LVM管理工具,比如RedHat下可以通過GUI進行管理,還可以通過CLI借口進行管理, 在RedHat AS 4中,對LVM進行升級,
推出了一個LVM管理平臺,我們在命令提示符下輸入LVM,就會進入這個平臺
[root@mayp lvm]# lvm
lvm> help
Available lvm commands:
Use 'lvm help <command>' for more information
dumpconfig Dump active configuration
formats List available metadata formats
help Display help for commands
lvchange Change the attributes of logical volume(s)
lvconvert Change logical volume layout
lvcreate Create a logical volume
lvdisplay Display information about a logical volume
lvextend Add space to a logical volume
lvmchange With the device mapper, this is obsolete and does nothing.
lvmdiskscan List devices that may be used as physical volumes
lvmsadc Collect activity data
lvmsar Create activity report
lvreduce Reduce the size of a logical volume
lvremove Remove logical volume(s) from the system
lvrename Rename a logical volume
lvresize Resize a logical volume
lvs Display information about logical volumes
lvscan List all logical volumes in all volume groups
pvchange Change attributes of physical volume(s)
pvresize Resize physical volume(s)
pvcreate Initialize physical volume(s) for use by LVM
pvdata Display the on-disk metadata for physical volume(s)
pvdisplay Display various attributes of physical volume(s)
pvmove Move extents from one physical volume to another
pvremove Remove LVM label(s) from physical volume(s)
pvs Display information about physical volumes
pvscan List all physical volumes
segtypes List available segment types
vgcfgbackup Backup volume group configuration(s)
vgcfgrestore Restore volume group configuration
vgchange Change volume group attributes
vgck Check the consistency of volume group(s)
vgconvert Change volume group metadata format
vgcreate Create a volume group
vgdisplay Display volume group information
vgexport Unregister volume group(s) from the system
vgextend Add physical volumes to a volume group
vgimport Register exported volume group with system
vgmerge Merge volume groups
vgmknodes Create the special files for volume group devices in /dev
vgreduce Remove physical volume(s) from a volume group
vgremove Remove volume group(s)
vgrename Rename a volume group
vgs Display information about volume groups
vgscan Search for all volume groups
vgsplit Move physical volumes into a new volume group
version Display software and driver version information
lvm> version
LVM version: 2.02.06 (2006-05-12)
Library version: 1.02.07 (2006-05-11)
Driver version: 4.5.0
lvm>
lvm> vgs -h
vgs: Display information about volume groups
vgs
[--aligned]
[-a|--all]
[-d|--debug]
[-h|--help]
[--ignorelockingfailure]
[--noheadings]
[--nosuffix]
[-o|--options [+]Field[,Field]]
[-O|--sort [+|-]key1[,[+|-]key2[,...]]]
[-P|--partial]
[--separator Separator]
[--unbuffered]
[--units hsbkmgtHKMGT]
[-v|--verbose]
[--version]
[VolumeGroupName [VolumeGroupName...]]
lvm> pvcreate -h
pvcreate: Initialize physical volume(s) for use by LVM
pvcreate
[--restorefile file]
[-d|--debug]
[-f[f]|--force [--force]]
[-h|-?|--help]
[--labelsector sector]
[-M|--metadatatype 1|2]
[--metadatacopies #copies]
[--metadatasize MetadataSize[kKmMgGtT]]
[--setphysicalvolumesize PhysicalVolumeSize[kKmMgGtT]
[-t|--test]
[-u|--uuid uuid]
[-v|--verbose]
[-y|--yes]
[-Z|--zero {y|n}]
[--version]
PhysicalVolume [PhysicalVolume...]
lvm>