How to do it...

To demonstrate RBD cloning, we will intentionally create an RBD image (specifying the layering feature) then create and protect its snapshot, and finally, create COW clones out of it:

  1. Create an RBD image with layering feature specified and check it's details:
        # rbd create rbd2 --size 10240 
--image-feature layering --name client.rbd
# rbd info --image rbd2 --name client.rbd
  1. Create a snapshot of this RBD image:
        # rbd snap create rbd/rbd2@snapshot_for_cloning 
--name client.rbd
  1. To create a COW clone, protect the snapshot. This is an important step, we should protect the snapshot because if the snapshot gets deleted, all the attached COW clones will be destroyed:
        # rbd snap protect rbd/rbd2@snapshot_for_cloning 
--name client.rbd
  1. Next, we will create a cloned RBD image, specifying the layering feature, using this snapshot. The syntax is as follows:
         # rbd clone <pool-name>/<parent-image-name>@<snap-name> 
<pool-name>/<child_image-name>
--image-feature <feature-name>

# rbd clone rbd/rbd2@snapshot_for_cloning rbd/clone_rbd2
--image-feature layering --name client.rbd
  1. Creating a clone is a quick process. Once it's completed, check the new image information. You will notice that its parent pool, image, and snapshot information will be displayed:
        # rbd info rbd/clone_rbd2 --name client.rbd

The clients do not always provide equivalent functionality, for example, the fuse client supports client-enforced quotas while the kernel client does not:

  1. You also have the ability to list children of a snapshot. To list the children of a snapshot execute the following:
        # rbd children rbd/rbd2@snapshot_for_cloning

We now have a cloned RBD image that is dependent on it's parent image. To split this cloned image from it's parent snapshot we will need to flatten the image which would require copying all the data from the parent snapshot image to the clone. Flattening may take awhile to complete and depends on the size of the parent snapshot image. One the cloned image is flattened there is no longer a relationship between the parent snapshot and the RBD clone. Please note that a flattened image will contain all information from the snapshot and will use more space than a clone.

  1. To initiate the flattening process, use the following:
        # rbd flatten rbd/clone_rbd2 --name client.rbd
# rbd info --image clone_rbd2 --name client.rbd

After the completion of the flattening process, if you check image information, you will notice that the parent image/snapshot name is not present and the clone is independent:

If the deep-flatten feature is enabled on an image the image clone is dissociated from its parent by default.

  1. You can also remove the parent image snapshot if you no longer require it. Before removing the snapshot, you first have to unprotect it:
        # rbd snap unprotect rbd/rbd2@snapshot_for_cloning 
--name client.rbd
  1. Once the snapshot is unprotected, you can remove it:
         # rbd snap rm rbd/rbd2@snapshot_for_cloning --name client.rbd 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset