After completing this section, you should be able to create and configure RADOS block devices snapshots and clones.
Images that use RBD format 2 support several optional features.
Use the rbd feature enable or rbd feature disable commands to enable or disable RBD image features.
This example enables the layering feature on the test image in the rbd pool.
[root@node ~]# rbd feature enable rbd/test layeringTo disable the layering feature, use the rbd feature disable command:
[root@node ~]# rbd feature disable rbd/test layeringThese are some of the available features for an RBD image:
Table 6.2. RBD Image Features
| Name | Description |
|---|---|
layering
| Layering support to enable cloning. |
striping
| Striping v2 support for enhanced performance, supported by librbd. |
exclusive-lock
| Exclusive locking support. |
object-map
| Object map support (requires exclusive-lock). |
fast-diff
| Fast diff command support (requires object-map AND exclusive-lock). |
deep-flatten
| Flattens all snapshots of the RBD image. |
journaling
| Journaling support. |
data-pool
| EC data pool support. |
RBD snapshots are read-only copies of an RBD image created at a particular time. RBD snapshots use a COW technique to reduce the amount of storage needed to maintain snapshots. Before applying a write I/O request to an RBD snapshot image, the cluster copies the original data to another area in the placement group of the object affected by the I/O operation. Snapshots do not consume any storage space when created, but grow in size as the objects that they contain change. RBD images support incremental snapshots.
Use the fsfreeze command to suspend access to a file system before taking a snapshot.
The fsfreeze -freeze command stops access to the file system and creates a stable image on disk.
Do not take a file system snapshot when the file system is not frozen because it will corrupt the snapshot's file system.
After taking the snapshot, use fsfreeze --unfreeze command to resume file system operations and access.
The snapshot COW procedure operates at the object level, regardless of the size of the write I/O request made to the RBD image. If you write a single byte to an RBD image that has a snapshot, then Ceph copies the entire affected object from the RBD image into the snapshot area.
Deleting an RBD image fails if snapshots exist for the image.
Use the rbd snap purge command to delete the snapshots.
Use the rbd snap create command to create a snapshot of a Ceph block device.
[root@node ~]# rbd snap create pool/image@firstsnap
Creating snap: 100% complete...done.Use the rbd snap ls command to list the block device snapshots.
[root@node ~]# rbd snap ls pool/image
SNAPID NAME SIZE PROTECTED TIMESTAMP
4 firstsnap 128 MiB Thu Oct 14 16:55:01 2021
7 secondsnap 128 MiB Thu Oct 14 17:48:59 2021Use the rbd snap rollback command to roll back a block device snapshot, overwriting the current version of the image with data from the snapshot.
[root@node ~]# rbd snap rollback pool/image@firstsnap
SNAPID NAME SIZE PROTECTED TIMESTAMP
4 firstsnap 128 MiB Thu Oct 14 16:55:01 2021
7 secondsnap 128 MiB Thu Oct 14 17:48:59 2021Use the rbd snap rm command to delete a snapshot for Ceph block devices.
[root@node ~]# rbd snap rm pool/image@secondsnap
Removing snap: 100% complete...done.RBD clones are read/write copies of an RBD image that use a protected RBD snapshot as a base. An RBD clone can also be flattened, which converts it into an RBD image independent of its source. The cloning process has three steps:
Create a snapshot:
[root@node ~]# rbd snap create pool/image@snapshot
Creating snap: 100% complete...done.Protect the snapshot from deletion:
[root@node ~]# rbd snap protect pool/image@snapshotCreate the clone using the protected snapshot:
[root@node ~]# rbd clone pool/imagename@snapshotname pool/clonenameThe newly created clone behaves just like a regular RBD image. Clones support COW and COR, with COW as the default. COW copies the parent snapshot data into the clone before applying a write I/O request to the clone.
You can also enable COR support for RBD clones. Data that is the same for the parent RBD snapshot and the clone is read directly from the parent. This can make reads more expensive if the parent's OSDs have high latency relative to the client. COR copies objects to the clone when they are first read.
If you enable COR, Ceph copies the data from the parent snapshot into the clone before processing a read I/O request, if the data is not already present in the clone.
Activate the COR feature by running the ceph config set client rbd_clone_copy_on_read true command or the ceph config set global rbd_clone_copy_on_read true command for the client or global setting.
The original data is not overwritten.
If COR is disabled on an RBD clone, every read operation that the clone cannot satisfy results in an I/O request to the parent of the clone.
The clone COW and COR procedures operate at the object level, regardless of the I/O request size. To read or write a single byte of the RBD clone, Ceph copies the entire object from the parent image or snapshot into the clone.
Use the rbd command to manage RBD clones.
| RBD commands for clone management | |
|---|---|
rbd children [
| List clones |
rbd clone [
| Create clone |
rbd flatten [
| Flatten clone |
When flattening a clone, Ceph copies all missing data from the parent into the clone and then removes the reference to the parent. The clone becomes an independent RBD image and is no longer the child of a protected snapshot.
You cannot delete RBD images directly from a pool.
Instead, use the rbd trash mv command to move an image from a pool to the trash.
Delete objects from the trash with the rbd trash rm command.
You are allowed to move active images that are in use by clones to the trash for later deletion.
For more information, refer to the Snapshot management chapter in the Red Hat Ceph Storage 5 Block Device Guide at https://access.redhat.com/documentation/en-us/red_hat_ceph_storage/5/html-single/block_device_guide/index#snapshot-management