本站教程收集整理的这篇文章主要介绍了CentOS 6.3下配置LVM(逻辑卷管理),本站教程本站觉得挺不错的,现在分享给大家,也给大家做个参考。
一、简介
LVM是逻辑盘卷管理(Logical Volume Manager)的简称,它是Linux环境下对磁盘分区进行管理的一种机制,LVM是建立在硬盘和分区之上的一个逻辑层,来提高磁盘分区管理的灵活性。
LVM的工作原理其实很简单,它就是通过将底层的物理硬盘抽象的封装起来,然后以逻辑卷的方式呈现给上层应用。在传统的磁盘管理机制中,我们的上层应用是直接访问文件系统,从而对底层的物理硬盘进行读取,而在LVM中,其通过对底层的硬盘进行封装,当我们对底层的物理硬盘进行操作时,其不再是针对于分区进行操作,而是通过一个叫做逻辑卷的东西来对其进行底层的磁盘管理操作。比如说我增加一个物理硬盘,这个时候上层的服务是感觉不到的,因为呈现给上层服务的是以逻辑卷的方式。
LVM最大的特点就是可以对磁盘进行动态管理。因为逻辑卷的大小是可以动态调整的,而且不会丢失现有的数据。如果我们新增加了硬盘,其也不会改变现有上层的逻辑卷。作为一个动态磁盘管理机制,逻辑卷技术大大提高了磁盘管理的灵活性。
基本的逻辑卷管理概念:
PV(Physical Volume)- 物理卷
物理卷在逻辑卷管理中处于最底层,它可以是实际物理硬盘上的分区,也可以是整个物理硬盘,也可以是raid设备。
VG(Volumne Group)- 卷组
卷组建立在物理卷之上,一个卷组中至少要包括一个物理卷,在卷组建立之后可动态添加物理卷到卷组中。一个逻辑卷管理系统工程中可以只有一个卷组,也可以拥有多个卷组。
LV(Logical Volume)- 逻辑卷
逻辑卷建立在卷组之上,卷组中的未分配空间可以用于建立新的逻辑卷,逻辑卷建立后可以动态地扩展和缩小空间。系统中的多个逻辑卷可以属于同一个卷组,也可以属于不同的多个卷组。
关系图如下:
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”600″ height=”360″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413290825011.jpg”>
PE(Physical Extent)- 物理块
LVM 默认使用4MB的PE区块,而LVM的LV最多仅能含有65534个PE (lvm1 的格式),因此默认的LVM的LV最大容量为4M*65534/(1024M/G)=256G。PE是整个LVM 最小的储存区块,也就是说,其实我们的资料都是由写入PE 来处理的。简单的说,这个PE 就有点像文件系统里面的block 大小。所以调整PE 会影响到LVM 的最大容量!不过,在 CentOS 6.x 以后,由于直接使用 lvm2 的各项格式功能,因此这个限制已经不存在了。
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”304″ height=”172″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413298796356.gif”>
二、系统环境
实验环境:Oracle VM VirtualBox
系统平台:CentOS release 6.3 (Final)
@H_7_2@mdadm 版本:@H_980_5@mdadm – v3.2.6 – 25th October 2012
LVM 版本:lvm2-2.02.100-8.el6.i686
设备类型:分区、物理硬盘、raid 设备
三、磁盘准备
在这篇文章中,我们将模拟raid5、分区、物理硬盘三种类型设备创建VG,raid5 需要四块硬盘,分区和物理硬盘各一块硬盘,还有扩容时需要至少一块硬盘,所以在虚拟机里添加八块硬盘,每块5GB.
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”642″ height=”494″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413315369427.jpg”>
四、安装LVM管理工具
4.1 检查系统中是否安装了LVM管理工具
# rpm -qa|grep lvm
4.2 如果未安装,则使用yum 方式安装
# yum install lvm*
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”340″ height=”97″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413328324157.jpg”>
五、新建一个raid5 设备
使用/dev/sdb,/dev/sdc,/dev/sdd,/dev/sde 四块物理硬盘做软raid模拟。
# mdadm -C /dev/md5 -ayes -l5 -n3 -x1 /dev/sd[b,c,d,e]
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”557″ height=”54″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413340368858.jpg”>
写入RAID配置文件/etc/mdadm.conf 并做适当修改。
# echo DEVICE /dev/sd{B,E} >> /etc/mdadm.conf
# mdadm ?CDs >> /etc/mdadm.conf
详细请参考上篇文章:http://www.cnblogs.com/mchina/p/linux-centos-disk-array-software_raid.html
六、新建一个分区
使用/dev/sdf 模拟分区。
# fdisk /dev/sdf
# fdisk -l /dev/sdf
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”679″ height=”669″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413359896188.jpg”>
准备工作就绪,下面我们使用三种设备/dev/md5、/dev/sdf1、/dev/sdg 来完成LVM实验。
七、创建PV
# pvcreate /dev/md5 /dev/sdf1 /dev/sdg
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”434″ height=”70″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413374117189.jpg”>
查看PV
# pvdisplay
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”515″ height=”500″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413389111448.jpg”>
还可以使用命令pvs 和pvscan 查看简略信息。
# pvs
便宜美国vps650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”344″ height=”84″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413413327620.jpg”>
# pvscan
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”553″ height=”83″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413442861123.jpg”>
八、创建VG
# vgcreate vg0 /dev/md5 /dev/sdf1 /dev/sdg
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”462″ height=”43″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413479738483.jpg”>
说明:vg0 是创建的VG设备的名称,可以随便取;后面接上述的三个设备,也就是把三个设备组合成一个vg0.
查看VG
# vgdisplay
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”512″ height=”305″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413493177227.jpg”>
说明:
VG Name VG的名称
VG Size VG的总大小
PE Size PE的大小,默认为4MB
@R_938_10586@l PE PE的总数量,5114 x 4MB = 19.98GB
Free PE / Size 剩余空间大小
同样可以使用命令vgs 和vgscan 查看。
# vgs
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”342″ height=”57″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413503798886.jpg”>
# vgscan
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”482″ height=”59″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413513325342.jpg”>
九、创建LV
# lvcreate -L 5G -n lv1 vg0
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”346″ height=”45″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413544115116.jpg”>
-L 指定创建的LV 的大小
-l 指定创建的LV 的PE 数量
-n LV的名字
上面命令的意思是:从vg0 中分出5G的空间给lv1 使用
查看LV的信息
# lvdisplay
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”524″ height=”253″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413557862103.jpg”>
LV Path LV的路径,全名
LV Name LV的名字
VG Name 所属的VG
LV Size LV的大小
再来看VG 的信息
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”341″ height=”62″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413568018747.jpg”>
VFree 从19.98g 减少到了14.98g,另外的5g 被分配到了lv1.
十、格式化LV
# mkfs.ext4 /dev/vg0/lv1
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”561″ height=”317″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413584572819.jpg”>
十一、挂载使用
# mkdir /mnt/lv1
# mount /dev/vg0/lv1 /mnt/lv1/
# df ?CTH
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”498″ height=”160″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171413598798521.jpg”>
将挂载信息写入/etc/fstab
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”786″ height=”242″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414014579335.jpg”>
十二、添加测试数据
下面我们将对LVM进行扩容和缩减操作,所以向/mnt/lv1 中写入测试数据以验证LVM 的磁盘动态管理。
# touch /mnt/lv1/test_lvm_dynamic.disk
# touch /mnt/lv1/test_lvm_dynamic.disk2
# touch /mnt/lv1/test_lvm_dynamic.disk3
# ll /mnt/lv1/
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”545″ height=”136″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414031456352.jpg”>
十三、LVM的扩容操作
LVM最大的好处就是可以对磁盘进行动态管理,而且不会丢失现有的数据。
假如有一天,lv1的使用量达到了80%,需要扩容,那我们该怎么做呢?
因为vg0中还有很多剩余空间,所以我们可以从vg0中再分配点空间给lv1。
13.1 LV的扩容
查看vg0 的剩余容量,还有14.98g 可用。
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”341″ height=”62″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414043173810.jpg”>
对lv1进行扩容。
# lvextend -L +1G /dev/vg0/lv1
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”361″ height=”58″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414052861739.jpg”>
说明:在lv1原有的基础上增加了1G.
查看现在vg0 的剩余容量,减少了1G.
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”349″ height=”57″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414061762112.jpg”>
再查看lv1的容量,从5G增加到了6G.
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”611″ height=”53″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414070676783.jpg”>
使用df ?CTH 命令查看实际的磁盘容量。
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”482″ height=”110″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414081763456.jpg”>
发现实际容量并没有变化,因为我们的系统还不认识刚刚添加进来的磁盘的文件系统,所以还需要对文件系统进行扩容。
# resize2fs /dev/vg0/lv1
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”634″ height=”202″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414096292701.jpg”>
现在的可用容量已经增加到了5.9G。
查看测试数据
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”551″ height=”97″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414108484172.jpg”>
数据正常,对lv1的在线动态扩容完成。
还有一种情况,就是假如我们的vg0 空间不够用了,怎么办?这时我们就需要对VG进行扩容。
13.2 VG的扩容
VG的扩容可以有两种方法,第一种方法是通过增加PV来实现,操作如下:
A. 创建PV,使用/dev/sdh 来创建一个PV。
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”428″ height=”45″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414117707087.jpg”>
B. 扩容VG
现在的vg0 容量为19.98g.
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”349″ height=”57″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414127076772.jpg”>
# vgextend vg0 /dev/sdh
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”375″ height=”97″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414138647459.jpg”>
现在vg0 的容量为24.97g,增加了5GB,即一块物理硬盘的容量,VG扩容成功。
第二种方法是通过扩展RAID设备的容量来间接对VG进行扩容。这种方法在上一篇文章中有介绍,这里不再赘述,需要注意的地方是,/dev/md5 的大小变化后,需要调整PV的大小,操作如下:
# pvresize /dev/md5
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”547″ height=”58″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414153019932.jpg”>
十四、LVM的缩减操作
缩减操作需要离线处理。
14.1 LV的缩减
A. umount 文件系统
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”481″ height=”144″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414163955133.jpg”>
B. 缩减文件系统
# resize2fs /dev/vg0/lv1 4G
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”374″ height=”66″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414174268548.jpg”>
提示需要先运行磁盘检查。
C. 检查磁盘
# e2fsck ?Cf /dev/vg0/lv1
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”609″ height=”118″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414187233278.jpg”>
D. 再次执行缩减操作
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”542″ height=”56″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414200207007.jpg”>
缩减文件系统成功,下面缩减LV的大小。
E. 缩减LV
# lvreduce /dev/vg0/lv1 ?CL 4G
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”626″ height=”197″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414212863494.jpg”>
说明:Step E 和Step D 缩减的大小必须保持一致,这里的4G是缩减到的大小;如果使用的是”-4G”,则表示容量减少多少的意思。
F. 挂载查看
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”497″ height=”135″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414225988695.jpg”>
LV 缩减成功。
G. 查看测试数据
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”542″ height=”96″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414238326938.jpg”>
数据正常。
14.2 VG的缩减
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”277″ height=”27″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414247702325.jpg”>
B. 查看当前的PV详情
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”343″ height=”92″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414258489754.jpg”>
C. 将/dev/sdg 从vg0 中移除
# vgreduce vg0 /dev/sdg
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”380″ height=”40″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414268177683.jpg”>
D. 再次查看PV情况
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”342″ height=”92″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414279421128.jpg”>
/dev/sdg 已经不属于vg0了。
E. 查看vg0 的情况
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”336″ height=”53″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414289118056.jpg”>
vg0 的大小减少了5GB.
VG 缩减成功。
十五、删除LVM
如果要彻底的来移除LVM的话,需要把创建的步骤反过来操作。
15.1 umount 文件系统
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”277″ height=”27″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414297866957.jpg”>
15.2 移除LV
# lvremove /dev/vg0/lv1
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”602″ height=”121″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414308488615.jpg”>
15.3 移除VG
# vgremove vg0
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”368″ height=”109″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414320514317.jpg”>
15.4 移除PV
# pvremove /dev/md5 /dev/sdf1 /dev/sdg /dev/sdh
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”500″ height=”174″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414334573845.jpg”>
LVM 移除成功。
十六、LVM 快照(snapshot)
快照就是将当时的系统信息记录下来,就好像照相一样,未来若有任何资料变动了,则原始资料会被移动到快照区,没有被改动的区域则由快照区与档案系统共享。
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”530″ height=”197″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414345513747.gif”>
LVM 系统快照区域的备份示意图(虚线为档案系统,长虚线为快照区)
左图为最初建立系统快照区的状况,LVM 会预留一个区域 (左图的左侧三个PE 区块) 作为数据存放处。此时快照区内并没有任何数据,而快照区与系统区共享所有的PE 数据, 因此你会看到快照区的内容与文件系统是一模一样的。等到系统运作一阵子后,假设A 区域的数据被更动了 (上面右图所示),则更动前系统会将该区域的数据移动到快照区,所以在右图的快照区被占用了一块PE 成为A,而其他B 到I 的区块则还是与文件系统共享!
快照区与被快照的LV 必须要在同一个VG 里。
16.1 建立LV
# lvcreate -L 100M -n lv1 vg0
16.2 写入测试数据
# touch /mnt/lv1/test_lvm_snapshot_1
# touch /mnt/lv1/test_lvm_snapshot_2
# cp -a /etc/ /mnt/lv1/
# cp -a /boot/ /mnt/lv1/
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”542″ height=”251″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414359118261.jpg”>
16.3 创建快照
# lvcreate -L 80M -s -n lv1snap /dev/vg0/lv1
说明:为/dev/vg0/lv1 创建一个大小为80M,名称为lv1snap 的快照。
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”533″ height=”604″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414376459291.jpg”>
/dev/vg0/lv1snap 的LV Size 为100MB,使用量为0.01%.
16.4 将刚才创建的快照挂载查看
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”571″ height=”131″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414390671293.jpg”>
/mnt/lv1 和/mnt/snapshot 是一模一样的。
16.5 进行档案的修改操作
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”528″ height=”339″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414406148565.jpg”>
16.6 再次查看
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”578″ height=”664″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414423328123.jpg”>
snapshot 的使用量为10.36%,原始资料有改动。
16.7 对snapshot 里的资料进行打包备份,准备还原
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”437″ height=”79″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414434898810.jpg”>
16.8 卸载并移除snapshot
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”569″ height=”144″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414449893069.jpg”>
16.9 卸载并格式化/mnt/lv1,清空数据
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”553″ height=”326″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414466295071.jpg”>
16.10 恢复数据
650) this.width=650;” src=”http://img.code.cc/vcimg/static/loading.png” width=”518″ height=”161″ border=”0″ style=”margin:0px;padding:0px;border:0px;BACkground-image:none;” src=”http://images.cnitblog.com/blog/370046/201406/171414479117327.jpg”>
可以看到,原始数据已经成功恢复。
LVM 快照实验成功。
注意:对lv1的修改量不能超过快照的大小,由于原始数据会被搬移到快照区,如果你的快照区不够大,若原始资料被更动的实际数据量比快照区大,那么快照区当然容纳不了,这时候快照功能会失效喔!
本站总结
以上是本站教程为你收集整理的CentOS 6.3下配置LVM(逻辑卷管理)全部内容,希望文章能够帮你解决CentOS 6.3下配置LVM(逻辑卷管理)所遇到的程序开发问题。
如果觉得本站教程网站内容还不错,欢迎将本站教程推荐给好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。