您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > 计算机应用/办公自动化 > 计算机培训课件-LVM
一、什么是LVM?称为逻辑卷管理器,以卷为单位,放弃传统硬盘以分区为磁盘单位的这种方法,动态调整卷的大小,实现弹性的调整磁盘空间。LVM2支持功能:可以在线调整卷的大小可以建立卷的快照二、LVM的组成物理卷(PV):一个物理的硬盘(/dev/hda1、/dev/hda2)也就是磁盘上分区卷组(VG):将物理卷合并为一个抽象的概念物理块(PE):当一个物理卷加入卷组时,它的空间被分为大小均匀的小的组块。物理块的大小在创建卷组时可以指定。默认4MB逻辑卷(LV):理解是磁盘上的分区三、创建物理卷(1)准备硬盘,并分区(2)使用pvcreate命令创建物理卷语法:pvcreate设备名[root@localhost/]#pvcreate/dev/sdb1/dev/sdc1/dev/sdd1Physicalvolume/dev/sdb1successfullycreatedPhysicalvolume/dev/sdc1successfullycreatedPhysicalvolume/dev/sdd1successfullycreated四、创建卷组语法:vgcreateVGNAMEPVDEVICES...VGNAME:卷组的名称,我们可以自定义名称,但是注意该名称是唯一的,不要和/dev/其它设备名冲突。Pvdevices:是组成卷组的物理卷设备名[root@localhost/]#vgcreatevg0/dev/sd{b,c,d}1Volumegroupvg0successfullycreated五、创建逻辑卷语法:lvcreate[-LSIZE]-nLVNAMEVGNAMESIZE:逻辑卷的大小,如果没有指定SIZE,则将卷组所有可用空间作为该逻辑卷的大小。LVNAME:逻辑卷的名称VGNAME:卷组名称[root@localhost/]#lvcreate-L150MB-nlv0vg0Roundingupsizetofullphysicalextent152.00MBLogicalvolumelv0created为什么我们创建的是150M的逻辑卷,而创建了一个152MB的LV?答:卷组中物理卷将分成大小为4mb的PE,创建逻辑卷,卷组中的PE映射到逻辑卷中,也就是逻辑卷有大小为4MB的虚拟空间组成,一定是4mb的倍数。[root@localhost/]#[root@localhost/]#ls/dev/vg0/lv0当创建一个逻辑卷后,linux会自动产生逻辑卷的设备文件,一般是以/dev/VGNAME/LVNAME,可以使用/dev/VGNAME/中的内容判断有多少个LV六、卸载卷注意事项:卸载逻辑卷:最好先备份数据,由于文件系统是建立在逻辑卷上,当卸载逻辑卷后,文件系统也就不复存在。卸载卷组:先卸载该卷组上的所有逻辑卷,同理,卸载物理卷前,须先卸载卷组(1)卸载逻辑卷语法:lvremoveLVNAME[root@localhost/]#lvremove/dev/vg0/lv0Doyoureallywanttoremoveactivelogicalvolumelv0?[y/n]:yLogicalvolumelv0successfullyremoved(2)卸载卷组语法:vgremoveVGname[root@localhost/]#vgremovevg0Volumegroupvg0successfullyremoved(3)卸载物理卷语法:pvremovePVDEVICEroot@localhost/]#pvremove/dev/sd{b,c,d}1七、查看卷信息查看物理卷:pvdisplayPVDEVICE查看卷组:vgdisplayVGNAME查看逻辑卷:lvdisplayLVDEVICE(1)[root@localhost/]#pvdisplay/dev/sdb1---Physicalvolume---PVName/dev/sdb1VGNamevg0PVSize19.99GB/notusable1.43MBAllocatableyesPESize(KByte)4096TotalPE5118FreePE5080AllocatedPE38PVUUIDqrZ5h3-A79O-0QYg-1F3C-rqW4-Iti7-naVHS4(2)[root@localhost/]#vgdisplay---Volumegroup---VGNamevg0SystemIDFormatlvm2MetadataAreas2MetadataSequenceNo2VGAccessread/writeVGStatusresizableMAXLV0CurLV1OpenLV0MaxPV0CurPV2ActPV2VGSize39.98GBPESize4.00MBTotalPE10236AllocPE/Size38/152.00MBFreePE/Size10198/39.84GBVGUUIDlwaj3z-SQTh-DOxx-msIp-CN1i-x1SJ-utxZQI[root@localhost/]#lvdisplay---Logicalvolume---LVName/dev/vg0/lv0VGNamevg0LVUUIDtmutYa-nOS3-kBpr-NW4f-arej-rOqh-3vloY0LVWriteAccessread/writeLVStatusavailable#open0LVSize152.00MBCurrentLE38Segments1AllocationinheritReadaheadsectorsauto-currentlysetto256Blockdevice253:0八、调整卷组要放大卷组,有额外的物理卷vgextendVGNAMEPVDEVICE...VGNAME:卷组的名称PVDEVICE:物理卷的名称(1)添加物理卷添加硬盘并分区[root@localhost/]#pvcreate/dev/sdd1Physicalvolume/dev/sdd1successfullycreated(2)将物理卷加入到卷组中[root@localhost/]#vgdisplay|grepVGSizeVGSize39.98GB[root@localhost/]#vgextendvg0/dev/sdd1Volumegroupvg0successfullyextended[root@localhost/]#vgdisplay|grepVGSizeVGSize59.98GB要缩小[root@localhost/]#vgdisplay|grepVGSizeVGSize59.98GB[root@localhost/]#vgreducevg0/dev/sdd1Removed/dev/sdd1fromvolumegroupvg0[root@localhost/]#vgdisplay|grepVGSizeVGSize39.98GB九、调整逻辑卷按照如下步骤调整逻辑卷:放大先放大LV,然后在放大文件系统缩小先缩小文件系统,在缩小LV[root@localhost/]#mkfs-text3/dev/vg0/lv0[root@localhost/]#mkdir/lv0[root@localhost/]#mount/dev/vg0/lv0/lv0/[root@localhost/]#df-h文件系统容量已用可用已用%挂载点/dev/sda3115G2.1G107G2%//dev/sda199M12M83M12%/boottmpfs506M0506M0%/dev/shm/dev/mapper/vg0-lv0148M5.6M135M4%/lv0放大:[root@localhost/]#lvdisplay/dev/vg0/lv0|grepLVSizeLVSize152.00MB[root@localhost/]#lvextend-L+50M/dev/vg0/lv0Roundingupsizetofullphysicalextent52.00MBExtendinglogicalvolumelv0to204.00MBLogicalvolumelv0successfullyresized[root@localhost/]#lvdisplay/dev/vg0/lv0|grepLVSizeLVSize204.00MBroot@localhost/]#umount/lv0/[root@localhost/]#e2fsck–f/dev/vg0/lv0[root@localhost/]#resize2fs/dev/vg0/lv0resize2fs1.39(29-May-2006)Thefilesystemisalready208896blockslong.Nothingtodo![root@localhost/]#mount/dev/vg0/lv0/lv0/[root@localhost/]#df-h文件系统容量已用可用已用%挂载点/dev/sda3115G2.1G107G2%//dev/sda199M12M83M12%/boottmpfs506M0506M0%/dev/shm/dev/mapper/vg0-lv0198M5.8M182M4%/lv0缩小:先缩小文件系统,然后缩小LV[root@localhost/]#umount/lv0/[root@localhost/]#e2fsck-f/dev/vg0/lv0e2fsck1.39(29-May-2006)Pass1:Checkinginodes,blocks,andsizesPass2:CheckingdirectorystructurePass3:CheckingdirectoryconnectivityPass4:CheckingreferencecountsPass5:Checkinggroupsummaryinformation/dev/vg0/lv0:11/53248files(9.1%non-contiguous),12643/208896blocks[root@localhost/]#resize2fs/dev/vg0/lv0140Mresize2fs1.39(29-May-2006)Resizingthefilesystemon/dev/vg0/lv0to143360(1k)blocks.Thefilesystemon/dev/vg0/lv0isnow143360blockslong.[root@localhost/]#lvreduce-L-60M/dev/vg0/lv0WARNING:Reducingactivelogicalvolumeto144.00MBTHISMAYDESTROYYOURDATA(filesystemetc.)Doyoureallywanttoreducelv0?[y/n]:yReducinglogicalvolumelv0to144.00MBLogicalvolumelv0successfullyresized[root@localhost/]#lvdisplay/dev/vg0/lv0|grepLVSizeLVSize144.00MB[root@localhost/]#mount/dev/vg0/lv0/lv0/[root@localhost/]#df-h文件系统容量已用可用已用%挂载点/dev/sda3115G2.1G107G2%//dev/sda199M12M83M12%/boottmpfs506M0506M0%/dev/shm/dev/mapper/vg0-lv0136M5.6M125M5%/lv0[root@localhost/]#十、安装时创建逻辑卷十一、自动挂载/etc/fstab/dev/vg0/lv0/lv0ext3defaults00十二、LVM卷快照卷快照:保存创建快照当时状态,可以利用该功能备份文件系统中的数据内容。创建快照时候,保存所有的文
本文标题:计算机培训课件-LVM
链接地址:https://www.777doc.com/doc-8447237 .html