|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
欢迎大家来到仓酷云论坛!明天就写一篇关于lvm逻辑卷的文章,自己关于lvm晓得的也不是良多,只是依据想要完成的功效,用到了lvm快照。
LVM先容:
LVM(LogicalVolumeManager)即逻辑卷办理器,它开始是在Linux2.4内核中被集成到内核中往的,它的呈现改动了传统的磁盘空间办理理念。以往在装置操纵体系时必要计划好分区巨细,即便使用了RAID手艺也要计划好每一个分区的巨细,由于一旦分好区后要改动其巨细长短常坚苦的事变。在Windows下有人人熟习的PartitionMagic工具能够用来调剂分区巨细,但它有一个弱点是要末在调剂前要封闭体系或调剂后重启体系。
这在一般PC机上利用还行,要在供应不中断办事的办事器上利用就会形成办事中止,不外这个成绩在Linux下跟着LV手艺的呈现统统都失掉办理,LV能够在不必重启体系的情形静态增添可用空间巨细,不外条件得是利用热插拔硬盘,或事前将硬盘装进而不利用。本文我将利用名词LV(可不是LV包)而不是LVM,由于LV才是配角。
起首我们要弄分明LV支付的几个关头名词观点:
物理介质:就是我们一般说的硬盘,简称pm
物理卷:就是我们一般说的硬盘分区,简称pv
物理分区:它是由LVM下令在物理卷上创立的最小LVM寻址单位,在创立物理卷时能够指定物理分区的巨细,默许值是4M,简称pe
卷组:由一个多多个物理卷构成的逻辑单位,简称vg
逻辑分区:它与物理分区逐一对应,巨细相称,简称le
逻辑卷:从卷组平分配必定巨细的空间创立的逻辑单位,也能够利用一个完全的卷组空间巨细来创立一个逻辑卷,简称lv
(lvm先容摘抄与51cto上)
1,创立物理卷PV
起首在2块磁盘上创立分区,这个分区会转成物理卷PV
- 123456789101112131415161718192021222324
复制代码- [root@xyly~]#fdisk-lDisk/dev/sda:42.9GB,42949672960bytes255heads,63sectors/track,5221cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sda1*11310439183Linux/dev/sda214128810241437+83Linux/dev/sda3128919255116702+83Linux/dev/sda419265221264751205Extended/dev/sda519262056105222682Linuxswap/Solaris/dev/sda6205752212542283183LinuxDisk/dev/sdb:10.7GB,10737418240bytes255heads,63sectors/track,1305cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sdb1113051048238183LinuxDisk/dev/sdc:10.7GB,10737418240bytes255heads,63sectors/track,1305cylindersUnits=cylindersof16065*512=8225280bytes
复制代码
以上是我格局化好的2个/dev/sdb1和/dev/sdbc1.
2,把分区转成物理卷pv
- [root@xyly~]#pvcreate/dev/sdb1Physicalvolume"/dev/sdb1"successfullycreated[root@xyly~]#pvcreate/dev/sdc1Physicalvolume"/dev/sdc1"successfullycreated
复制代码
利用pvdisplay检察体系一切的pv信息大概指定的单个
- 12345678910111213141516171819202122
复制代码- [root@xyly~]#pvdisplay---Physicalvolume---PVName/dev/sdb1VGNamenyvg1PVSize10.00GB/notusable717.00KBAllocatableyesPESize(KByte)4096TotalPE2559FreePE2506AllocatedPE53PVUUIDW23uI8-kZ46-4W3y-L0tW-Za22-nMeG-YbLeoD---Physicalvolume---PVName/dev/sdc1VGNamenyvg1PVSize10.00GB/notusable717.00KBAllocatableyesPESize(KByte)4096TotalPE2559FreePE2521AllocatedPE38PVUUIDMzv5fV-xret-4IyG-s2fC-py33-mvCW-iBVF0Z
复制代码
3,创立VG卷组
- 12345678910111213141516171819202122232425
复制代码- [root@xyly~]#[root@xyly~]#vgcreatelvm001/dev/sd[bc]1#讲/dev/sdb1和/dev/sdbc1到场到卷组lvm001中/dev/cdrom:openfailed:Read-onlyfilesystemVolumegroup"lvm001"successfullycreated[root@xyly~]#vgdisplay#利用vgdisplay检察卷组---Volumegroup---VGNamelvm001SystemIDFormatlvm2MetadataAreas2MetadataSequenceNo1VGAccessread/writeVGStatusresizableMAXLV0CurLV0OpenLV0MaxPV0CurPV2ActPV2VGSize19.99GBPESize4.00MB#默许的PE巨细为4MTotalPE5118AllocPE/Size0/0FreePE/Size5118/19.99GB#一共5118个pe,未利用的。VGUUIDoKhjBB-L9At-I2KC-Zrd3-fR2g-QoTe-3x0AST
复制代码
4,创立逻辑卷LV
- 123456789101112131415161718192021222324252627282930313233343536
复制代码- [root@xyly~]#lvcreate-L1000-ntest1lvm001#-L分派给lv的空间巨细。-n是创立逻辑卷的名字Logicalvolume"test1"created#创立乐成[root@xyly~]#lvcreate-L1000M-ntest2lvm001#-lL分派给lv空间的巨细Logicalvolume"test2"created[root@xyly~]#lvdisplay#检察LV的信息---Logicalvolume---LVName/dev/lvm001/test1VGNamelvm001LVUUIDZiqMqR-XqD6-tNuv-dnv1-6a1C-PN0n-ZmRP2TLVWriteAccessread/writeLVStatusavailable#open0LVSize1000.00MBCurrentLE250Segments1AllocationinheritReadaheadsectorsauto-currentlysetto256Blockdevice253:0---Logicalvolume---LVName/dev/lvm001/test2VGNamelvm001LVUUIDoDWKde-dLeM-HsEi-CHOr-b9TF-SH3J-Gh6esLLVWriteAccessread/writeLVStatusavailable#open0LVSize1000.00MBCurrentLE250Segments1AllocationinheritReadaheadsectorsauto-currentlysetto256Blockdevice253:1
复制代码
把这2个LV格局化为ext3文件体系
- [root@xyly~]#fdisk-lDisk/dev/sda:42.9GB,42949672960bytes255heads,63sectors/track,5221cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sda1*11310439183Linux/dev/sda214128810241437+83Linux/dev/sda3128919255116702+83Linux/dev/sda419265221264751205Extended/dev/sda519262056105222682Linuxswap/Solaris/dev/sda6205752212542283183LinuxDisk/dev/sdb:10.7GB,10737418240bytes255heads,63sectors/track,1305cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sdb1113051048238183LinuxDisk/dev/sdc:10.7GB,10737418240bytes255heads,63sectors/track,1305cylindersUnits=cylindersof16065*512=8225280bytes0
复制代码- [root@xyly~]#fdisk-lDisk/dev/sda:42.9GB,42949672960bytes255heads,63sectors/track,5221cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sda1*11310439183Linux/dev/sda214128810241437+83Linux/dev/sda3128919255116702+83Linux/dev/sda419265221264751205Extended/dev/sda519262056105222682Linuxswap/Solaris/dev/sda6205752212542283183LinuxDisk/dev/sdb:10.7GB,10737418240bytes255heads,63sectors/track,1305cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sdb1113051048238183LinuxDisk/dev/sdc:10.7GB,10737418240bytes255heads,63sectors/track,1305cylindersUnits=cylindersof16065*512=8225280bytes1
复制代码
都能够格局化为ext3的文件体系
格局化终了。如今要挂载
- [root@xyly~]#fdisk-lDisk/dev/sda:42.9GB,42949672960bytes255heads,63sectors/track,5221cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sda1*11310439183Linux/dev/sda214128810241437+83Linux/dev/sda3128919255116702+83Linux/dev/sda419265221264751205Extended/dev/sda519262056105222682Linuxswap/Solaris/dev/sda6205752212542283183LinuxDisk/dev/sdb:10.7GB,10737418240bytes255heads,63sectors/track,1305cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sdb1113051048238183LinuxDisk/dev/sdc:10.7GB,10737418240bytes255heads,63sectors/track,1305cylindersUnits=cylindersof16065*512=8225280bytes2
复制代码- [root@xyly~]#fdisk-lDisk/dev/sda:42.9GB,42949672960bytes255heads,63sectors/track,5221cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sda1*11310439183Linux/dev/sda214128810241437+83Linux/dev/sda3128919255116702+83Linux/dev/sda419265221264751205Extended/dev/sda519262056105222682Linuxswap/Solaris/dev/sda6205752212542283183LinuxDisk/dev/sdb:10.7GB,10737418240bytes255heads,63sectors/track,1305cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sdb1113051048238183LinuxDisk/dev/sdc:10.7GB,10737418240bytes255heads,63sectors/track,1305cylindersUnits=cylindersof16065*512=8225280bytes3
复制代码
挂载逻辑卷终了。
5,创立lvm快照。
- [root@xyly~]#fdisk-lDisk/dev/sda:42.9GB,42949672960bytes255heads,63sectors/track,5221cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sda1*11310439183Linux/dev/sda214128810241437+83Linux/dev/sda3128919255116702+83Linux/dev/sda419265221264751205Extended/dev/sda519262056105222682Linuxswap/Solaris/dev/sda6205752212542283183LinuxDisk/dev/sdb:10.7GB,10737418240bytes255heads,63sectors/track,1305cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sdb1113051048238183LinuxDisk/dev/sdc:10.7GB,10737418240bytes255heads,63sectors/track,1305cylindersUnits=cylindersof16065*512=8225280bytes4
复制代码- [root@xyly~]#fdisk-lDisk/dev/sda:42.9GB,42949672960bytes255heads,63sectors/track,5221cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sda1*11310439183Linux/dev/sda214128810241437+83Linux/dev/sda3128919255116702+83Linux/dev/sda419265221264751205Extended/dev/sda519262056105222682Linuxswap/Solaris/dev/sda6205752212542283183LinuxDisk/dev/sdb:10.7GB,10737418240bytes255heads,63sectors/track,1305cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sdb1113051048238183LinuxDisk/dev/sdc:10.7GB,10737418240bytes255heads,63sectors/track,1305cylindersUnits=cylindersof16065*512=8225280bytes5
复制代码
快照创立完成,下边演示快照的感化。
<divclass="wp_syntax"style="margin:0px0px1.5em;padding:0px;list-style:none;color:rgb(17,0,0);background-color:rgb(249,249,249);border:1pxsolidsilver;overflow-y:hidden;overflow-x:auto;width:707.84375px;font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:19.5px;">- [root@xyly~]#fdisk-lDisk/dev/sda:42.9GB,42949672960bytes255heads,63sectors/track,5221cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sda1*11310439183Linux/dev/sda214128810241437+83Linux/dev/sda3128919255116702+83Linux/dev/sda419265221264751205Extended/dev/sda519262056105222682Linuxswap/Solaris/dev/sda6205752212542283183LinuxDisk/dev/sdb:10.7GB,10737418240bytes255heads,63sectors/track,1305cylindersUnits=cylindersof16065*512=8225280bytesDeviceBootStartEndBlocksIdSystem/dev/sdb1113051048238183LinuxDisk/dev/sdc:10.7GB,10737418240bytes255heads,63sectors/track,1305cylindersUnits=cylindersof16065*512=8225280bytes6
复制代码 [code][root@xyly~]#mount/dev/lvm001/test2/lvm1#挂载test2到/lvm1(前边用的是test1)[root@xyly~]#ls/lvm1#检察/lvm1目次下的内容,如今只要一个文件夹lost+found[root@xyly~]#touch/lvm1/test{1,2,3,4,5,6}#在/lvm1目次下创立测试文件[root@xyly~]#ls/lvm1lost+foundtest1test2test3test4test5test6#创立的文件[root@xyly~]#mkdir/snap#创立快照挂载点[root@xyly~ |
|