逻辑卷的快照
操作方法
- 01
使用-s参数来生成一个快照卷,使用-L参数来指定切割的大小,另外要记得在后面写上这个快照是针对那个LV逻辑卷设备做的。 [root@linuxprobe ~]# lvcreate -L 120M -s -n SNAP /dev/storage/vo Logical volume "SNAP" created [root@linuxprobe ~]# lvdisplay --- Logical volume --- LV Path /dev/storage/SNAP LV Name SNAP VG Name storage LV UUID BC7WKg-fHoK-Pc7J-yhSd-vD7d-lUnl-TihKlt LV Write Access read/write LV Creation host, time localhost.localdomain, 2017-02-01 07:42:31 -0500 LV snapshot status active destination for vo LV Status available # open 0 LV Size 120.00 MiB Current LE 30 COW-table size 120.00 MiB COW-table LE 30 Allocated to snapshot 0.01% Snapshot chunk size 4.00 KiB Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:3 ………………省略部分输出信息………………
- 02
在LV设备卷所挂载的目录中创建一个100M的垃圾文件,这样再来看快照卷的状态就会发现使用率上升了: [root@linuxprobe ~]# dd if=/dev/zero of=/linuxprobe/files count=1 bs=100M 1+0 records in 1+0 records out 104857600 bytes (105 MB) copied, 3.35432 s, 31.3 MB/s [root@linuxprobe ~]# lvdisplay --- Logical volume --- LV Path /dev/storage/SNAP LV Name SNAP VG Name storage LV UUID BC7WKg-fHoK-Pc7J-yhSd-vD7d-lUnl-TihKlt LV Write Access read/write LV Creation host, time localhost.localdomain, 2017-02-01 07:42:31 -0500 LV snapshot status active destination for vo LV Status available # open 0 LV Size 120.00 MiB Current LE 30 COW-table size 120.00 MiB COW-table LE 30 Allocated to snapshot 83.71% Snapshot chunk size 4.00 KiB Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:3
- 03
为了校验SNAP快照卷的效果,需要对逻辑卷进行快照合并还原操作,在这之前记得先卸载掉逻辑卷设备与目录的挂载~ [root@linuxprobe ~]# umount /linuxprobe [root@linuxprobe ~]# lvconvert --merge /dev/storage/SNAP Merging of volume SNAP started. vo: Merged: 21.4% vo: Merged: 100.0% Merge of snapshot into logical volume vo has finished. Logical volume "SNAP" successfully removed
- 04
快照卷会被自动删除掉,并且刚刚在逻辑卷设备被快照后再创建出来的100M垃圾文件也被清除了: [root@linuxprobe ~]# mount -a [root@linuxprobe ~]# ls /linuxprobe/ lost+found readme.txt