官术网_书友最值得收藏!

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 it's 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 
主站蜘蛛池模板: 玉山县| 福贡县| 专栏| 新乐市| 德安县| 灵宝市| 咸宁市| 攀枝花市| 泾川县| 镇原县| 福贡县| 乐安县| 铜陵市| 利津县| 连山| 和政县| 荆州市| 汕头市| 五寨县| 宜宾县| 界首市| 乌鲁木齐市| 皮山县| 渝中区| 桐柏县| 浑源县| 张家口市| 深州市| 贡山| 县级市| 万全县| 咸丰县| 乌恰县| 安泽县| 邵阳市| 聂拉木县| 新余市| 广汉市| 靖远县| 卢龙县| 永嘉县|