3.3.6. 快照卷
LVM 的快照性能为您提供了在某个特定时刻,在不导致服务中断的情况下创建设备的虚拟映射可能性。在提取快照后,当对原始设备进行修改时,快照特性会和在修改前提取快照一样提供一个修改了的数据区域的副本,以便重建设备的状态。
注意
As of the Red Hat Enterprise Linux 6.4 release, LVM supports thinly-provisioned snapshots. For information on thinly provisioned snapshot volumes, see 第 3.3.7 节 “Thinly-Provisioned Snapshot Volumes”.
注意
LVM snapshots are not supported across the nodes in a cluster. You cannot create a snapshot volume in a clustered volume group.
Because a snapshot copies only the data areas that change after the snapshot is created, the snapshot feature requires a minimal amount of storage. For example, with a rarely updated origin, 3-5 % of the origin's capacity is sufficient to maintain the snapshot.
注意
文件系统的快照副本是虚拟副本,不是文件系统的真实介质备份。快照不是备份过程的替代行为。
The size of the snapshot governs the amount of space set aside for storing the changes to the origin volume. For example, if you made a snapshot and then completely overwrote the origin the snapshot would have to be at least as big as the origin volume to hold the changes. You need to dimension a snapshot according to the expected level of change. So for example a short-lived snapshot of a read-mostly volume, such as
/usr, would need less space than a long-lived snapshot of a volume that sees a greater number of writes, such as /home.
If a snapshot runs full, the snapshot becomes invalid, since it can no longer track changes on the origin volume. You should regularly monitor the size of the snapshot. Snapshots are fully resizeable, however, so if you have the storage capacity you can increase the size of the snapshot volume to prevent it from getting dropped. Conversely, if you find that the snapshot volume is larger than you need, you can reduce the size of the volume to free up space that is needed by other logical volumes.
当您创建文件系统的快照时,仍可能对源系统有完全的读和写访问。如果快照中的一个块修改了,那么就会标记出那个块,并再不从原始卷中复制这个块。
快照特性有几个用途:
- 最典型的就是,当您需要在逻辑卷中在不影响运行系统连续性的情况下执行备份操作时可提取一个快照,这样可以持续地更新数据。
- 您可以在快照文件系统中执行
fsck命令来检查文件系统的完整性,并确定源文件系统是否需要修复。 - 因为快照是可读/写的,您可以通过获取快照并根据快照进行测试,来进行根据产品数据测试应用程序,而不会影响真实数据。
- You can create LVM volumes for use with Red Hat virtualization. LVM snapshots can be used to create snapshots of virtual guest images. These snapshots can provide a convenient way to modify existing guests or create new guests with minimal additional storage. For information on creating LVM-based storage pools with Red Hat Virtualization, see the Virtualization Administration Guide.
For information on creating snapshot volumes, see 第 5.4.5 节 “创建快照卷”.
As of the Red Hat Enterprise Linux 6 release, you can use the
--merge option of the lvconvert command to merge a snapshot into its origin volume. One use for this feature is to perform system rollback if you have lost data or files or otherwise need to restore your system to a previous state. After you merge the snapshot volume, the resulting logical volume will have the origin volume's name, minor number, and UUID and the merged snapshot is removed. For information on using this option, see 第 5.4.8 节 “Merging Snapshot Volumes”.